Skip to content

Commit 7e8c8f0

Browse files
committed
Polishing
1 parent f965123 commit 7e8c8f0

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

spring-core/src/main/java/org/springframework/core/type/ClassMetadata.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -63,19 +63,18 @@ public interface ClassMetadata {
6363
boolean isFinal();
6464

6565
/**
66-
* Determine whether the underlying class is independent,
67-
* i.e. whether it is a top-level class or a nested class
68-
* (static inner class) that can be constructed independent
69-
* from an enclosing class.
66+
* Determine whether the underlying class is independent, i.e. whether
67+
* it is a top-level class or a nested class (static inner class) that
68+
* can be constructed independently from an enclosing class.
7069
*/
7170
boolean isIndependent();
7271

7372
/**
74-
* Return whether the underlying class has an enclosing class
75-
* (i.e. the underlying class is an inner/nested class or
76-
* a local class within a method).
77-
* <p>If this method returns {@code false}, then the
78-
* underlying class is a top-level class.
73+
* Return whether the underlying class is declared within an enclosing
74+
* class (i.e. the underlying class is an inner/nested class or a
75+
* local class within a method).
76+
* <p>If this method returns {@code false}, then the underlying
77+
* class is a top-level class.
7978
*/
8079
boolean hasEnclosingClass();
8180

spring-core/src/main/java/org/springframework/core/type/StandardClassMetadata.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
2121

2222
import org.springframework.lang.Nullable;
2323
import org.springframework.util.Assert;
24+
import org.springframework.util.StringUtils;
2425

2526
/**
2627
* {@link ClassMetadata} implementation that uses standard reflection
@@ -124,11 +125,11 @@ public String[] getInterfaceNames() {
124125

125126
@Override
126127
public String[] getMemberClassNames() {
127-
LinkedHashSet<String> memberClassNames = new LinkedHashSet<>();
128+
LinkedHashSet<String> memberClassNames = new LinkedHashSet<>(4);
128129
for (Class<?> nestedClass : this.introspectedClass.getDeclaredClasses()) {
129130
memberClassNames.add(nestedClass.getName());
130131
}
131-
return memberClassNames.toArray(new String[memberClassNames.size()]);
132+
return StringUtils.toStringArray(memberClassNames);
132133
}
133134

134135
}

spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.springframework.core.type.ClassMetadata;
3030
import org.springframework.lang.Nullable;
3131
import org.springframework.util.ClassUtils;
32+
import org.springframework.util.StringUtils;
3233

3334
/**
3435
* ASM class visitor which looks only for the class name and implemented types,
@@ -64,7 +65,7 @@ class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata
6465

6566
private String[] interfaces = new String[0];
6667

67-
private Set<String> memberClassNames = new LinkedHashSet<>();
68+
private Set<String> memberClassNames = new LinkedHashSet<>(4);
6869

6970

7071
public ClassMetadataReadingVisitor() {
@@ -208,7 +209,7 @@ public String[] getInterfaceNames() {
208209

209210
@Override
210211
public String[] getMemberClassNames() {
211-
return this.memberClassNames.toArray(new String[this.memberClassNames.size()]);
212+
return StringUtils.toStringArray(this.memberClassNames);
212213
}
213214

214215

0 commit comments

Comments
 (0)