From f2fb0ec9e730f274420e0d5cfa1585aec2217f75 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 21 Aug 2013 17:37:06 +0200 Subject: [PATCH] Minor polishing of related files Issue: SPR-10181 --- .../AnnotationScopeMetadataResolver.java | 4 +--- .../core/annotation/AnnotationUtils.java | 4 ++-- .../core/type/AnnotatedTypeMetadata.java | 15 +++++++-------- .../AnnotationMetadataReadingVisitor.java | 10 ++++------ 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java index 788f8043c6..878638b68b 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java @@ -23,8 +23,6 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.util.Assert; -import static org.springframework.context.annotation.MetadataUtils.*; - /** * A {@link ScopeMetadataResolver} implementation that by default checks for * the presence of Spring's {@link Scope} annotation on the bean class. @@ -79,7 +77,7 @@ public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver { ScopeMetadata metadata = new ScopeMetadata(); if (definition instanceof AnnotatedBeanDefinition) { AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition; - AnnotationAttributes attributes = attributesFor(annDef.getMetadata(), this.scopeAnnotationType); + AnnotationAttributes attributes = MetadataUtils.attributesFor(annDef.getMetadata(), this.scopeAnnotationType); if (attributes != null) { metadata.setScopeName(attributes.getString("value")); ScopedProxyMode proxyMode = attributes.getEnum("proxyMode"); diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index 46847d0823..5d5f317a68 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -419,8 +419,8 @@ public abstract class AnnotationUtils { Annotation[] realAnnotations = (Annotation[]) value; AnnotationAttributes[] mappedAnnotations = new AnnotationAttributes[realAnnotations.length]; for (int i = 0; i < realAnnotations.length; i++) { - mappedAnnotations[i] = getAnnotationAttributes(realAnnotations[i], classValuesAsString, - nestedAnnotationsAsMap); + mappedAnnotations[i] = getAnnotationAttributes( + realAnnotations[i], classValuesAsString, nestedAnnotationsAsMap); } attrs.put(method.getName(), mappedAnnotations); } diff --git a/spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java b/spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java index 4cef1d48b3..60c9cf2647 100644 --- a/spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java @@ -75,9 +75,9 @@ public interface AnnotatedTypeMetadata { * Retrieve all attributes of all annotations of the given type, if any (i.e. if * defined on the underlying method, as direct annotation or as meta-annotation). * @param annotationType the annotation type to look for - * @return a MultiMap of attributes, with the attribute name as key (e.g. "value") and - * a list of the defined attribute values as Map value. This return value will - * be {@code null} if no matching annotation is defined. + * @return a MultiMap of attributes, with the attribute name as key (e.g. "value") + * and a list of the defined attribute values as Map value. This return value will + * be {@code null} if no matching annotation is defined. */ MultiValueMap getAllAnnotationAttributes(String annotationType); @@ -86,12 +86,11 @@ public interface AnnotatedTypeMetadata { * defined on the underlying method, as direct annotation or as meta-annotation). * @param annotationType the annotation type to look for * @param classValuesAsString whether to convert class references to String - * @return a MultiMap of attributes, with the attribute name as key (e.g. "value") and - * a list of the defined attribute values as Map value. This return value will - * be {@code null} if no matching annotation is defined. + * @return a MultiMap of attributes, with the attribute name as key (e.g. "value") + * and a list of the defined attribute values as Map value. This return value will + * be {@code null} if no matching annotation is defined. * @see #getAllAnnotationAttributes(String) */ - MultiValueMap getAllAnnotationAttributes(String annotationType, - boolean classValuesAsString); + MultiValueMap getAllAnnotationAttributes(String annotationType, boolean classValuesAsString); } diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java index 6f5679c65b..c12b83d160 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java @@ -115,8 +115,7 @@ public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisito public AnnotationAttributes getAnnotationAttributes(String annotationType, boolean classValuesAsString) { List attributes = this.attributeMap.get(annotationType); AnnotationAttributes raw = (attributes == null ? null : attributes.get(0)); - return AnnotationReadingVisitorUtils.convertClassValues(this.classLoader, raw, - classValuesAsString); + return AnnotationReadingVisitorUtils.convertClassValues(this.classLoader, raw, classValuesAsString); } @Override @@ -125,16 +124,15 @@ public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisito } @Override - public MultiValueMap getAllAnnotationAttributes( - String annotationType, boolean classValuesAsString) { + public MultiValueMap getAllAnnotationAttributes(String annotationType, boolean classValuesAsString) { MultiValueMap allAttributes = new LinkedMultiValueMap(); List attributes = this.attributeMap.get(annotationType); if (attributes == null) { return null; } for (AnnotationAttributes raw : attributes) { - for (Map.Entry entry : AnnotationReadingVisitorUtils.convertClassValues( - this.classLoader, raw, classValuesAsString).entrySet()) { + for (Map.Entry entry : + AnnotationReadingVisitorUtils.convertClassValues(this.classLoader, raw, classValuesAsString).entrySet()) { allAttributes.add(entry.getKey(), entry.getValue()); } }