Polishing
This commit removes unnecessary not-null checks for annotation attribute alias names.
This commit is contained in:
parent
164bed5c3f
commit
a066143a5b
|
|
@ -91,25 +91,23 @@ abstract class AbstractAliasAwareAnnotationAttributeExtractor<S> implements Anno
|
||||||
if (aliasNames != null) {
|
if (aliasNames != null) {
|
||||||
final Object defaultValue = AnnotationUtils.getDefaultValue(getAnnotationType(), attributeName);
|
final Object defaultValue = AnnotationUtils.getDefaultValue(getAnnotationType(), attributeName);
|
||||||
for (String aliasName : aliasNames) {
|
for (String aliasName : aliasNames) {
|
||||||
if (aliasName != null) {
|
Object aliasValue = getRawAttributeValue(aliasName);
|
||||||
Object aliasValue = getRawAttributeValue(aliasName);
|
|
||||||
|
|
||||||
if (!ObjectUtils.nullSafeEquals(attributeValue, aliasValue) &&
|
if (!ObjectUtils.nullSafeEquals(attributeValue, aliasValue) &&
|
||||||
!ObjectUtils.nullSafeEquals(attributeValue, defaultValue) &&
|
!ObjectUtils.nullSafeEquals(attributeValue, defaultValue) &&
|
||||||
!ObjectUtils.nullSafeEquals(aliasValue, defaultValue)) {
|
!ObjectUtils.nullSafeEquals(aliasValue, defaultValue)) {
|
||||||
String elementName = (getAnnotatedElement() != null ? getAnnotatedElement().toString() : "unknown element");
|
String elementName = (getAnnotatedElement() != null ? getAnnotatedElement().toString() : "unknown element");
|
||||||
throw new AnnotationConfigurationException(String.format(
|
throw new AnnotationConfigurationException(String.format(
|
||||||
"In annotation [%s] declared on %s and synthesized from [%s], attribute '%s' and its " +
|
"In annotation [%s] declared on %s and synthesized from [%s], attribute '%s' and its " +
|
||||||
"alias '%s' are present with values of [%s] and [%s], but only one is permitted.",
|
"alias '%s' are present with values of [%s] and [%s], but only one is permitted.",
|
||||||
getAnnotationType().getName(), elementName, getSource(), attributeName, aliasName,
|
getAnnotationType().getName(), elementName, getSource(), attributeName, aliasName,
|
||||||
ObjectUtils.nullSafeToString(attributeValue), ObjectUtils.nullSafeToString(aliasValue)));
|
ObjectUtils.nullSafeToString(attributeValue), ObjectUtils.nullSafeToString(aliasValue)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user didn't declare the annotation with an explicit value,
|
// If the user didn't declare the annotation with an explicit value,
|
||||||
// use the value of the alias instead.
|
// use the value of the alias instead.
|
||||||
if (ObjectUtils.nullSafeEquals(attributeValue, defaultValue)) {
|
if (ObjectUtils.nullSafeEquals(attributeValue, defaultValue)) {
|
||||||
attributeValue = aliasValue;
|
attributeValue = aliasValue;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,13 +99,11 @@ class MapAnnotationAttributeExtractor extends AbstractAliasAwareAnnotationAttrib
|
||||||
List<String> aliasNames = attributeAliasMap.get(attributeName);
|
List<String> aliasNames = attributeAliasMap.get(attributeName);
|
||||||
if (aliasNames != null) {
|
if (aliasNames != null) {
|
||||||
for (String aliasName : aliasNames) {
|
for (String aliasName : aliasNames) {
|
||||||
if (aliasName != null) {
|
Object aliasValue = attributes.get(aliasName);
|
||||||
Object aliasValue = attributes.get(aliasName);
|
if (aliasValue != null) {
|
||||||
if (aliasValue != null) {
|
attributeValue = aliasValue;
|
||||||
attributeValue = aliasValue;
|
attributes.put(attributeName, attributeValue);
|
||||||
attributes.put(attributeName, attributeValue);
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue