Skip to content

Commit d5974a1

Browse files
committed
Polish AnnotationUtils
1 parent a1fc209 commit d5974a1

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public abstract class AnnotationUtils {
118118
private static final Map<Class<? extends Annotation>, Boolean> synthesizableCache =
119119
new ConcurrentReferenceHashMap<Class<? extends Annotation>, Boolean>(256);
120120

121-
private static final Map<Class<? extends Annotation>, Map<String, String>> attributeAliasCache =
121+
private static final Map<Class<? extends Annotation>, Map<String, String>> attributeAliasesCache =
122122
new ConcurrentReferenceHashMap<Class<? extends Annotation>, Map<String, String>>(256);
123123

124124
private static transient Log logger;
@@ -437,11 +437,11 @@ private static <A extends Annotation> A searchOnInterfaces(Method method, Class<
437437
}
438438

439439
static boolean isInterfaceWithAnnotatedMethods(Class<?> iface) {
440-
Boolean flag = annotatedInterfaceCache.get(iface);
441-
if (flag != null) {
442-
return flag.booleanValue();
440+
Boolean found = annotatedInterfaceCache.get(iface);
441+
if (found != null) {
442+
return found.booleanValue();
443443
}
444-
Boolean found = Boolean.FALSE;
444+
found = Boolean.FALSE;
445445
for (Method ifcMethod : iface.getMethods()) {
446446
try {
447447
if (ifcMethod.getAnnotations().length > 0) {
@@ -831,14 +831,12 @@ static AnnotationAttributes getAnnotationAttributes(AnnotatedElement annotatedEl
831831
for (Method method : getAttributeMethods(annotationType)) {
832832
try {
833833
Object value = method.invoke(annotation);
834-
835834
Object defaultValue = method.getDefaultValue();
836835
if (defaultValuesAsPlaceholder && (defaultValue != null)) {
837836
if (ObjectUtils.nullSafeEquals(value, defaultValue)) {
838837
value = DEFAULT_VALUE_PLACEHOLDER;
839838
}
840839
}
841-
842840
attrs.put(method.getName(),
843841
adaptValue(annotatedElement, value, classValuesAsString, nestedAnnotationsAsMap));
844842
}
@@ -1090,12 +1088,12 @@ private static Map<String, String> getAttributeAliasMap(Class<? extends Annotati
10901088
return Collections.emptyMap();
10911089
}
10921090

1093-
Map<String, String> cachedMap = attributeAliasCache.get(annotationType);
1094-
if (cachedMap != null) {
1095-
return cachedMap;
1091+
Map<String, String> map = attributeAliasesCache.get(annotationType);
1092+
if (map != null) {
1093+
return map;
10961094
}
10971095

1098-
Map<String, String> map = new HashMap<String, String>();
1096+
map = new HashMap<String, String>();
10991097
for (Method attribute : getAttributeMethods(annotationType)) {
11001098
String attributeName = attribute.getName();
11011099
String aliasedAttributeName = getAliasedAttributeName(attribute);
@@ -1104,7 +1102,7 @@ private static Map<String, String> getAttributeAliasMap(Class<? extends Annotati
11041102
}
11051103
}
11061104

1107-
attributeAliasCache.put(annotationType, map);
1105+
attributeAliasesCache.put(annotationType, map);
11081106

11091107
return map;
11101108
}
@@ -1127,12 +1125,12 @@ private static Map<String, String> getAttributeAliasMap(Class<? extends Annotati
11271125
@SuppressWarnings("unchecked")
11281126
private static boolean isSynthesizable(Class<? extends Annotation> annotationType) {
11291127

1130-
Boolean flag = synthesizableCache.get(annotationType);
1131-
if (flag != null) {
1132-
return flag.booleanValue();
1128+
Boolean synthesizable = synthesizableCache.get(annotationType);
1129+
if (synthesizable != null) {
1130+
return synthesizable.booleanValue();
11331131
}
11341132

1135-
Boolean synthesizable = Boolean.FALSE;
1133+
synthesizable = Boolean.FALSE;
11361134

11371135
for (Method attribute : getAttributeMethods(annotationType)) {
11381136
if (getAliasedAttributeName(attribute) != null) {
@@ -1306,7 +1304,8 @@ static String getAliasedAttributeName(Method attribute, Class<? extends Annotati
13061304
* <p>All methods in the returned list will be
13071305
* {@linkplain ReflectionUtils#makeAccessible(Method) made accessible}.
13081306
*
1309-
* @param annotationType the type in which to search for attribute methods
1307+
* @param annotationType the type in which to search for attribute methods;
1308+
* never {@code null}
13101309
* @return all annotation attribute methods in the specified annotation
13111310
* type; never {@code null}, though potentially <em>empty</em>
13121311
* @since 4.2

0 commit comments

Comments
 (0)