Polishing
This commit is contained in:
parent
95453a4427
commit
f054c2e804
|
|
@ -101,15 +101,13 @@ public class AnnotationBeanNameGenerator implements BeanNameGenerator {
|
||||||
@Nullable
|
@Nullable
|
||||||
protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) {
|
protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) {
|
||||||
AnnotationMetadata metadata = annotatedDef.getMetadata();
|
AnnotationMetadata metadata = annotatedDef.getMetadata();
|
||||||
Set<String> annotationTypes = metadata.getAnnotationTypes();
|
|
||||||
|
|
||||||
String explicitBeanName = getExplicitBeanName(metadata);
|
String beanName = getExplicitBeanName(metadata);
|
||||||
if (explicitBeanName != null) {
|
if (beanName != null) {
|
||||||
return explicitBeanName;
|
return beanName;
|
||||||
}
|
}
|
||||||
|
|
||||||
String beanName = null;
|
for (String annotationType : metadata.getAnnotationTypes()) {
|
||||||
for (String annotationType : annotationTypes) {
|
|
||||||
AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(metadata, annotationType);
|
AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(metadata, annotationType);
|
||||||
if (attributes != null) {
|
if (attributes != null) {
|
||||||
Set<String> metaAnnotationTypes = this.metaAnnotationTypesCache.computeIfAbsent(annotationType, key -> {
|
Set<String> metaAnnotationTypes = this.metaAnnotationTypesCache.computeIfAbsent(annotationType, key -> {
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ import org.springframework.core.annotation.MergedAnnotations;
|
||||||
public interface AnnotationMetadata extends ClassMetadata, AnnotatedTypeMetadata {
|
public interface AnnotationMetadata extends ClassMetadata, AnnotatedTypeMetadata {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the fully qualified class names of all annotation types that
|
* Get the fully-qualified class names of all annotation types that are
|
||||||
* are <em>present</em> on the underlying class.
|
* <em>directly present</em> on the underlying class.
|
||||||
* @return the annotation type names
|
* @return the annotation type names
|
||||||
*/
|
*/
|
||||||
default Set<String> getAnnotationTypes() {
|
default Set<String> getAnnotationTypes() {
|
||||||
|
|
@ -52,9 +52,9 @@ public interface AnnotationMetadata extends ClassMetadata, AnnotatedTypeMetadata
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the fully qualified class names of all meta-annotation types that
|
* Get the fully-qualified class names of all meta-annotation types that are
|
||||||
* are <em>present</em> on the given annotation type on the underlying class.
|
* <em>present</em> on the given annotation type on the underlying class.
|
||||||
* @param annotationName the fully qualified class name of the annotation
|
* @param annotationName the fully-qualified class name of the annotation
|
||||||
* type to look for meta-annotations on
|
* type to look for meta-annotations on
|
||||||
* @return the meta-annotation type names, or an empty set if none found
|
* @return the meta-annotation type names, or an empty set if none found
|
||||||
*/
|
*/
|
||||||
|
|
@ -69,11 +69,11 @@ public interface AnnotationMetadata extends ClassMetadata, AnnotatedTypeMetadata
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether an annotation of the given type is <em>present</em> on
|
* Determine whether an annotation of the given type is <em>directly present</em>
|
||||||
* the underlying class.
|
* on the underlying class.
|
||||||
* @param annotationName the fully qualified class name of the annotation
|
* @param annotationName the fully-qualified class name of the annotation
|
||||||
* type to look for
|
* type to look for
|
||||||
* @return {@code true} if a matching annotation is present
|
* @return {@code true} if a matching annotation is directly present
|
||||||
*/
|
*/
|
||||||
default boolean hasAnnotation(String annotationName) {
|
default boolean hasAnnotation(String annotationName) {
|
||||||
return getAnnotations().isDirectlyPresent(annotationName);
|
return getAnnotations().isDirectlyPresent(annotationName);
|
||||||
|
|
@ -82,7 +82,7 @@ public interface AnnotationMetadata extends ClassMetadata, AnnotatedTypeMetadata
|
||||||
/**
|
/**
|
||||||
* Determine whether the underlying class has an annotation that is itself
|
* Determine whether the underlying class has an annotation that is itself
|
||||||
* annotated with the meta-annotation of the given type.
|
* annotated with the meta-annotation of the given type.
|
||||||
* @param metaAnnotationName the fully qualified class name of the
|
* @param metaAnnotationName the fully-qualified class name of the
|
||||||
* meta-annotation type to look for
|
* meta-annotation type to look for
|
||||||
* @return {@code true} if a matching meta-annotation is present
|
* @return {@code true} if a matching meta-annotation is present
|
||||||
*/
|
*/
|
||||||
|
|
@ -94,7 +94,7 @@ public interface AnnotationMetadata extends ClassMetadata, AnnotatedTypeMetadata
|
||||||
/**
|
/**
|
||||||
* Determine whether the underlying class has any methods that are
|
* Determine whether the underlying class has any methods that are
|
||||||
* annotated (or meta-annotated) with the given annotation type.
|
* annotated (or meta-annotated) with the given annotation type.
|
||||||
* @param annotationName the fully qualified class name of the annotation
|
* @param annotationName the fully-qualified class name of the annotation
|
||||||
* type to look for
|
* type to look for
|
||||||
*/
|
*/
|
||||||
default boolean hasAnnotatedMethods(String annotationName) {
|
default boolean hasAnnotatedMethods(String annotationName) {
|
||||||
|
|
@ -106,7 +106,7 @@ public interface AnnotationMetadata extends ClassMetadata, AnnotatedTypeMetadata
|
||||||
* (or meta-annotated) with the given annotation type.
|
* (or meta-annotated) with the given annotation type.
|
||||||
* <p>For any returned method, {@link MethodMetadata#isAnnotated} will
|
* <p>For any returned method, {@link MethodMetadata#isAnnotated} will
|
||||||
* return {@code true} for the given annotation type.
|
* return {@code true} for the given annotation type.
|
||||||
* @param annotationName the fully qualified class name of the annotation
|
* @param annotationName the fully-qualified class name of the annotation
|
||||||
* type to look for
|
* type to look for
|
||||||
* @return a set of {@link MethodMetadata} for methods that have a matching
|
* @return a set of {@link MethodMetadata} for methods that have a matching
|
||||||
* annotation. The return value will be an empty set if no methods match
|
* annotation. The return value will be an empty set if no methods match
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue