Skip to content

Commit 4208ec0

Browse files
committed
Polishing
(cherry picked from commit 7e8c8f0)
1 parent ab19c22 commit 4208ec0

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
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.
@@ -61,19 +61,18 @@ public interface ClassMetadata {
6161
boolean isFinal();
6262

6363
/**
64-
* Determine whether the underlying class is independent,
65-
* i.e. whether it is a top-level class or a nested class
66-
* (static inner class) that can be constructed independent
67-
* from an enclosing class.
64+
* Determine whether the underlying class is independent, i.e. whether
65+
* it is a top-level class or a nested class (static inner class) that
66+
* can be constructed independently from an enclosing class.
6867
*/
6968
boolean isIndependent();
7069

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

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-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.
@@ -20,6 +20,7 @@
2020
import java.util.LinkedHashSet;
2121

2222
import org.springframework.util.Assert;
23+
import org.springframework.util.StringUtils;
2324

2425
/**
2526
* {@link ClassMetadata} implementation that uses standard reflection
@@ -121,11 +122,11 @@ public String[] getInterfaceNames() {
121122

122123
@Override
123124
public String[] getMemberClassNames() {
124-
LinkedHashSet<String> memberClassNames = new LinkedHashSet<String>();
125+
LinkedHashSet<String> memberClassNames = new LinkedHashSet<String>(4);
125126
for (Class<?> nestedClass : this.introspectedClass.getDeclaredClasses()) {
126127
memberClassNames.add(nestedClass.getName());
127128
}
128-
return memberClassNames.toArray(new String[memberClassNames.size()]);
129+
return StringUtils.toStringArray(memberClassNames);
129130
}
130131

131132
}

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

Lines changed: 4 additions & 3 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.
@@ -28,6 +28,7 @@
2828
import org.springframework.asm.SpringAsmInfo;
2929
import org.springframework.core.type.ClassMetadata;
3030
import org.springframework.util.ClassUtils;
31+
import org.springframework.util.StringUtils;
3132

3233
/**
3334
* ASM class visitor which looks only for the class name and implemented types,
@@ -61,7 +62,7 @@ class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata
6162

6263
private String[] interfaces;
6364

64-
private Set<String> memberClassNames = new LinkedHashSet<String>();
65+
private Set<String> memberClassNames = new LinkedHashSet<String>(4);
6566

6667

6768
public ClassMetadataReadingVisitor() {
@@ -201,7 +202,7 @@ public String[] getInterfaceNames() {
201202

202203
@Override
203204
public String[] getMemberClassNames() {
204-
return this.memberClassNames.toArray(new String[this.memberClassNames.size()]);
205+
return StringUtils.toStringArray(this.memberClassNames);
205206
}
206207

207208

0 commit comments

Comments
 (0)