Browse Source

Polishing

pull/1578/head
Juergen Hoeller 7 years ago
parent
commit
7e8c8f0b76
  1. 19
      spring-core/src/main/java/org/springframework/core/type/ClassMetadata.java
  2. 7
      spring-core/src/main/java/org/springframework/core/type/StandardClassMetadata.java
  3. 5
      spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -63,19 +63,18 @@ public interface ClassMetadata { @@ -63,19 +63,18 @@ public interface ClassMetadata {
boolean isFinal();
/**
* Determine whether the underlying class is independent,
* i.e. whether it is a top-level class or a nested class
* (static inner class) that can be constructed independent
* from an enclosing class.
* Determine whether the underlying class is independent, i.e. whether
* it is a top-level class or a nested class (static inner class) that
* can be constructed independently from an enclosing class.
*/
boolean isIndependent();
/**
* Return whether the underlying class has an enclosing class
* (i.e. the underlying class is an inner/nested class or
* a local class within a method).
* <p>If this method returns {@code false}, then the
* underlying class is a top-level class.
* Return whether the underlying class is declared within an enclosing
* class (i.e. the underlying class is an inner/nested class or a
* local class within a method).
* <p>If this method returns {@code false}, then the underlying
* class is a top-level class.
*/
boolean hasEnclosingClass();

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,6 +21,7 @@ import java.util.LinkedHashSet; @@ -21,6 +21,7 @@ import java.util.LinkedHashSet;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* {@link ClassMetadata} implementation that uses standard reflection
@ -124,11 +125,11 @@ public class StandardClassMetadata implements ClassMetadata { @@ -124,11 +125,11 @@ public class StandardClassMetadata implements ClassMetadata {
@Override
public String[] getMemberClassNames() {
LinkedHashSet<String> memberClassNames = new LinkedHashSet<>();
LinkedHashSet<String> memberClassNames = new LinkedHashSet<>(4);
for (Class<?> nestedClass : this.introspectedClass.getDeclaredClasses()) {
memberClassNames.add(nestedClass.getName());
}
return memberClassNames.toArray(new String[memberClassNames.size()]);
return StringUtils.toStringArray(memberClassNames);
}
}

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

@ -29,6 +29,7 @@ import org.springframework.asm.SpringAsmInfo; @@ -29,6 +29,7 @@ import org.springframework.asm.SpringAsmInfo;
import org.springframework.core.type.ClassMetadata;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
* ASM class visitor which looks only for the class name and implemented types,
@ -64,7 +65,7 @@ class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata @@ -64,7 +65,7 @@ class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata
private String[] interfaces = new String[0];
private Set<String> memberClassNames = new LinkedHashSet<>();
private Set<String> memberClassNames = new LinkedHashSet<>(4);
public ClassMetadataReadingVisitor() {
@ -208,7 +209,7 @@ class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata @@ -208,7 +209,7 @@ class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata
@Override
public String[] getMemberClassNames() {
return this.memberClassNames.toArray(new String[this.memberClassNames.size()]);
return StringUtils.toStringArray(this.memberClassNames);
}

Loading…
Cancel
Save