Skip to content

Commit f054c2e

Browse files
committed
Polishing
1 parent 95453a4 commit f054c2e

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

spring-context/src/main/java/org/springframework/context/annotation/AnnotationBeanNameGenerator.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,13 @@ public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry
101101
@Nullable
102102
protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) {
103103
AnnotationMetadata metadata = annotatedDef.getMetadata();
104-
Set<String> annotationTypes = metadata.getAnnotationTypes();
105104

106-
String explicitBeanName = getExplicitBeanName(metadata);
107-
if (explicitBeanName != null) {
108-
return explicitBeanName;
105+
String beanName = getExplicitBeanName(metadata);
106+
if (beanName != null) {
107+
return beanName;
109108
}
110109

111-
String beanName = null;
112-
for (String annotationType : annotationTypes) {
110+
for (String annotationType : metadata.getAnnotationTypes()) {
113111
AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(metadata, annotationType);
114112
if (attributes != null) {
115113
Set<String> metaAnnotationTypes = this.metaAnnotationTypesCache.computeIfAbsent(annotationType, key -> {

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
public interface AnnotationMetadata extends ClassMetadata, AnnotatedTypeMetadata {
4141

4242
/**
43-
* Get the fully qualified class names of all annotation types that
44-
* are <em>present</em> on the underlying class.
43+
* Get the fully-qualified class names of all annotation types that are
44+
* <em>directly present</em> on the underlying class.
4545
* @return the annotation type names
4646
*/
4747
default Set<String> getAnnotationTypes() {
@@ -52,9 +52,9 @@ default Set<String> getAnnotationTypes() {
5252
}
5353

5454
/**
55-
* Get the fully qualified class names of all meta-annotation types that
56-
* are <em>present</em> on the given annotation type on the underlying class.
57-
* @param annotationName the fully qualified class name of the annotation
55+
* Get the fully-qualified class names of all meta-annotation types that are
56+
* <em>present</em> on the given annotation type on the underlying class.
57+
* @param annotationName the fully-qualified class name of the annotation
5858
* type to look for meta-annotations on
5959
* @return the meta-annotation type names, or an empty set if none found
6060
*/
@@ -69,11 +69,11 @@ default Set<String> getMetaAnnotationTypes(String annotationName) {
6969
}
7070

7171
/**
72-
* Determine whether an annotation of the given type is <em>present</em> on
73-
* the underlying class.
74-
* @param annotationName the fully qualified class name of the annotation
72+
* Determine whether an annotation of the given type is <em>directly present</em>
73+
* on the underlying class.
74+
* @param annotationName the fully-qualified class name of the annotation
7575
* type to look for
76-
* @return {@code true} if a matching annotation is present
76+
* @return {@code true} if a matching annotation is directly present
7777
*/
7878
default boolean hasAnnotation(String annotationName) {
7979
return getAnnotations().isDirectlyPresent(annotationName);
@@ -82,7 +82,7 @@ default boolean hasAnnotation(String annotationName) {
8282
/**
8383
* Determine whether the underlying class has an annotation that is itself
8484
* annotated with the meta-annotation of the given type.
85-
* @param metaAnnotationName the fully qualified class name of the
85+
* @param metaAnnotationName the fully-qualified class name of the
8686
* meta-annotation type to look for
8787
* @return {@code true} if a matching meta-annotation is present
8888
*/
@@ -94,7 +94,7 @@ default boolean hasMetaAnnotation(String metaAnnotationName) {
9494
/**
9595
* Determine whether the underlying class has any methods that are
9696
* annotated (or meta-annotated) with the given annotation type.
97-
* @param annotationName the fully qualified class name of the annotation
97+
* @param annotationName the fully-qualified class name of the annotation
9898
* type to look for
9999
*/
100100
default boolean hasAnnotatedMethods(String annotationName) {
@@ -106,7 +106,7 @@ default boolean hasAnnotatedMethods(String annotationName) {
106106
* (or meta-annotated) with the given annotation type.
107107
* <p>For any returned method, {@link MethodMetadata#isAnnotated} will
108108
* return {@code true} for the given annotation type.
109-
* @param annotationName the fully qualified class name of the annotation
109+
* @param annotationName the fully-qualified class name of the annotation
110110
* type to look for
111111
* @return a set of {@link MethodMetadata} for methods that have a matching
112112
* annotation. The return value will be an empty set if no methods match

0 commit comments

Comments
 (0)