Browse Source

Polishing

pull/946/head
Juergen Hoeller 9 years ago
parent
commit
8968f09c59
  1. 15
      spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java

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

@ -1985,16 +1985,14 @@ public abstract class AnnotationUtils {
if (this.isAliasPair) { if (this.isAliasPair) {
AliasFor mirrorAliasFor = this.aliasedAttribute.getAnnotation(AliasFor.class); AliasFor mirrorAliasFor = this.aliasedAttribute.getAnnotation(AliasFor.class);
if (mirrorAliasFor == null) { if (mirrorAliasFor == null) {
String msg = String.format( String msg = String.format("Attribute [%s] in annotation [%s] must be declared as an @AliasFor [%s].",
"Attribute [%s] in annotation [%s] must be declared as an @AliasFor [%s].",
this.aliasedAttributeName, this.sourceAnnotationType.getName(), this.sourceAttributeName); this.aliasedAttributeName, this.sourceAnnotationType.getName(), this.sourceAttributeName);
throw new AnnotationConfigurationException(msg); throw new AnnotationConfigurationException(msg);
} }
String mirrorAliasedAttributeName = getAliasedAttributeName(mirrorAliasFor, this.aliasedAttribute); String mirrorAliasedAttributeName = getAliasedAttributeName(mirrorAliasFor, this.aliasedAttribute);
if (!this.sourceAttributeName.equals(mirrorAliasedAttributeName)) { if (!this.sourceAttributeName.equals(mirrorAliasedAttributeName)) {
String msg = String.format( String msg = String.format("Attribute [%s] in annotation [%s] must be declared as an @AliasFor [%s], not [%s].",
"Attribute [%s] in annotation [%s] must be declared as an @AliasFor [%s], not [%s].",
this.aliasedAttributeName, this.sourceAnnotationType.getName(), this.sourceAttributeName, this.aliasedAttributeName, this.sourceAnnotationType.getName(), this.sourceAttributeName,
mirrorAliasedAttributeName); mirrorAliasedAttributeName);
throw new AnnotationConfigurationException(msg); throw new AnnotationConfigurationException(msg);
@ -2156,12 +2154,13 @@ public abstract class AnnotationUtils {
// Ensure user did not declare both 'value' and 'attribute' in @AliasFor // Ensure user did not declare both 'value' and 'attribute' in @AliasFor
if (attributeDeclared && valueDeclared) { if (attributeDeclared && valueDeclared) {
throw new AnnotationConfigurationException(String.format( String msg = String.format("In @AliasFor declared on attribute [%s] in annotation [%s], attribute 'attribute' " +
"In @AliasFor declared on attribute [%s] in annotation [%s], attribute 'attribute' and its " + "and its alias 'value' are present with values of [%s] and [%s], but only one is permitted.",
"alias 'value' are present with values of [%s] and [%s], but only one is permitted.", attribute.getName(), attribute.getDeclaringClass().getName(), attributeName, value);
attribute.getName(), attribute.getDeclaringClass().getName(), attributeName, value)); throw new AnnotationConfigurationException(msg);
} }
// Either explicit attribute name or pointing to same-named attribute by default
attributeName = (attributeDeclared ? attributeName : value); attributeName = (attributeDeclared ? attributeName : value);
return (StringUtils.hasText(attributeName) ? attributeName.trim() : attribute.getName()); return (StringUtils.hasText(attributeName) ? attributeName.trim() : attribute.getName());
} }

Loading…
Cancel
Save