Skip to content

Commit c88877f

Browse files
committed
Polishing
1 parent 9683da5 commit c88877f

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

spring-core/src/main/java/org/springframework/core/annotation/AbstractAliasAwareAnnotationAttributeExtractor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ abstract class AbstractAliasAwareAnnotationAttributeExtractor<S> implements Anno
5555
* of the supplied type; may be {@code null} if unknown
5656
* @param source the underlying source of annotation attributes; never {@code null}
5757
*/
58-
AbstractAliasAwareAnnotationAttributeExtractor(Class<? extends Annotation> annotationType,
59-
AnnotatedElement annotatedElement, S source) {
58+
AbstractAliasAwareAnnotationAttributeExtractor(
59+
Class<? extends Annotation> annotationType, AnnotatedElement annotatedElement, S source) {
6060

6161
Assert.notNull(annotationType, "annotationType must not be null");
6262
Assert.notNull(source, "source must not be null");
@@ -84,12 +84,12 @@ public final S getSource() {
8484

8585
@Override
8686
public final Object getAttributeValue(Method attributeMethod) {
87-
final String attributeName = attributeMethod.getName();
87+
String attributeName = attributeMethod.getName();
8888
Object attributeValue = getRawAttributeValue(attributeMethod);
8989

9090
List<String> aliasNames = this.attributeAliasMap.get(attributeName);
9191
if (aliasNames != null) {
92-
final Object defaultValue = AnnotationUtils.getDefaultValue(getAnnotationType(), attributeName);
92+
Object defaultValue = AnnotationUtils.getDefaultValue(getAnnotationType(), attributeName);
9393
for (String aliasName : aliasNames) {
9494
Object aliasValue = getRawAttributeValue(aliasName);
9595

spring-core/src/main/java/org/springframework/core/annotation/MapAnnotationAttributeExtractor.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -121,33 +121,33 @@ private static Map<String, Object> enrichAndValidateAttributes(
121121
// if still null
122122
if (attributeValue == null) {
123123
throw new IllegalArgumentException(String.format(
124-
"Attributes map [%s] returned null for required attribute [%s] defined by annotation type [%s].",
125-
attributes, attributeName, annotationType.getName()));
124+
"Attributes map [%s] returned null for required attribute [%s] defined by annotation type [%s].",
125+
attributes, attributeName, annotationType.getName()));
126126
}
127127

128128
// finally, ensure correct type
129129
Class<?> requiredReturnType = attributeMethod.getReturnType();
130130
Class<? extends Object> actualReturnType = attributeValue.getClass();
131+
131132
if (!ClassUtils.isAssignable(requiredReturnType, actualReturnType)) {
132133
boolean converted = false;
133134

134135
// Nested map representing a single annotation?
135-
if (Annotation.class.isAssignableFrom(requiredReturnType)
136-
&& Map.class.isAssignableFrom(actualReturnType)) {
137-
138-
Class<? extends Annotation> nestedAnnotationType = (Class<? extends Annotation>) requiredReturnType;
136+
if (Annotation.class.isAssignableFrom(requiredReturnType) &&
137+
Map.class.isAssignableFrom(actualReturnType)) {
138+
Class<? extends Annotation> nestedAnnotationType =
139+
(Class<? extends Annotation>) requiredReturnType;
139140
Map<String, Object> map = (Map<String, Object>) attributeValue;
140141
attributes.put(attributeName, synthesizeAnnotation(map, nestedAnnotationType, null));
141142
converted = true;
142143
}
143144

144145
// Nested array of maps representing an array of annotations?
145-
else if (requiredReturnType.isArray()
146-
&& Annotation.class.isAssignableFrom(requiredReturnType.getComponentType())
147-
&& actualReturnType.isArray()
148-
&& Map.class.isAssignableFrom(actualReturnType.getComponentType())) {
149-
150-
Class<? extends Annotation> nestedAnnotationType = (Class<? extends Annotation>) requiredReturnType.getComponentType();
146+
else if (requiredReturnType.isArray() && actualReturnType.isArray() &&
147+
Annotation.class.isAssignableFrom(requiredReturnType.getComponentType()) &&
148+
Map.class.isAssignableFrom(actualReturnType.getComponentType())) {
149+
Class<? extends Annotation> nestedAnnotationType =
150+
(Class<? extends Annotation>) requiredReturnType.getComponentType();
151151
Map<String, Object>[] maps = (Map<String, Object>[]) attributeValue;
152152
attributes.put(attributeName, synthesizeAnnotationArray(maps, nestedAnnotationType));
153153
converted = true;

spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public void metaAnnotationOverridesUsingAnnotationMetadataReadingVisitor() throw
194194

195195
private void assertMetaAnnotationOverrides(AnnotationMetadata metadata) {
196196
AnnotationAttributes attributes = (AnnotationAttributes) metadata.getAnnotationAttributes(
197-
TestComponentScan.class.getName(), false);
197+
TestComponentScan.class.getName(), false);
198198
String[] basePackages = attributes.getStringArray("basePackages");
199199
assertThat("length of basePackages[]", basePackages.length, is(1));
200200
assertThat("basePackages[0]", basePackages[0], is("org.example.componentscan"));

0 commit comments

Comments
 (0)