Polishing
This commit is contained in:
parent
9683da52b2
commit
c88877f1c4
|
|
@ -55,8 +55,8 @@ abstract class AbstractAliasAwareAnnotationAttributeExtractor<S> implements Anno
|
|||
* of the supplied type; may be {@code null} if unknown
|
||||
* @param source the underlying source of annotation attributes; never {@code null}
|
||||
*/
|
||||
AbstractAliasAwareAnnotationAttributeExtractor(Class<? extends Annotation> annotationType,
|
||||
AnnotatedElement annotatedElement, S source) {
|
||||
AbstractAliasAwareAnnotationAttributeExtractor(
|
||||
Class<? extends Annotation> annotationType, AnnotatedElement annotatedElement, S source) {
|
||||
|
||||
Assert.notNull(annotationType, "annotationType must not be null");
|
||||
Assert.notNull(source, "source must not be null");
|
||||
|
|
@ -84,12 +84,12 @@ abstract class AbstractAliasAwareAnnotationAttributeExtractor<S> implements Anno
|
|||
|
||||
@Override
|
||||
public final Object getAttributeValue(Method attributeMethod) {
|
||||
final String attributeName = attributeMethod.getName();
|
||||
String attributeName = attributeMethod.getName();
|
||||
Object attributeValue = getRawAttributeValue(attributeMethod);
|
||||
|
||||
List<String> aliasNames = this.attributeAliasMap.get(attributeName);
|
||||
if (aliasNames != null) {
|
||||
final Object defaultValue = AnnotationUtils.getDefaultValue(getAnnotationType(), attributeName);
|
||||
Object defaultValue = AnnotationUtils.getDefaultValue(getAnnotationType(), attributeName);
|
||||
for (String aliasName : aliasNames) {
|
||||
Object aliasValue = getRawAttributeValue(aliasName);
|
||||
|
||||
|
|
|
|||
|
|
@ -128,26 +128,26 @@ class MapAnnotationAttributeExtractor extends AbstractAliasAwareAnnotationAttrib
|
|||
// finally, ensure correct type
|
||||
Class<?> requiredReturnType = attributeMethod.getReturnType();
|
||||
Class<? extends Object> actualReturnType = attributeValue.getClass();
|
||||
|
||||
if (!ClassUtils.isAssignable(requiredReturnType, actualReturnType)) {
|
||||
boolean converted = false;
|
||||
|
||||
// Nested map representing a single annotation?
|
||||
if (Annotation.class.isAssignableFrom(requiredReturnType)
|
||||
&& Map.class.isAssignableFrom(actualReturnType)) {
|
||||
|
||||
Class<? extends Annotation> nestedAnnotationType = (Class<? extends Annotation>) requiredReturnType;
|
||||
if (Annotation.class.isAssignableFrom(requiredReturnType) &&
|
||||
Map.class.isAssignableFrom(actualReturnType)) {
|
||||
Class<? extends Annotation> nestedAnnotationType =
|
||||
(Class<? extends Annotation>) requiredReturnType;
|
||||
Map<String, Object> map = (Map<String, Object>) attributeValue;
|
||||
attributes.put(attributeName, synthesizeAnnotation(map, nestedAnnotationType, null));
|
||||
converted = true;
|
||||
}
|
||||
|
||||
// Nested array of maps representing an array of annotations?
|
||||
else if (requiredReturnType.isArray()
|
||||
&& Annotation.class.isAssignableFrom(requiredReturnType.getComponentType())
|
||||
&& actualReturnType.isArray()
|
||||
&& Map.class.isAssignableFrom(actualReturnType.getComponentType())) {
|
||||
|
||||
Class<? extends Annotation> nestedAnnotationType = (Class<? extends Annotation>) requiredReturnType.getComponentType();
|
||||
else if (requiredReturnType.isArray() && actualReturnType.isArray() &&
|
||||
Annotation.class.isAssignableFrom(requiredReturnType.getComponentType()) &&
|
||||
Map.class.isAssignableFrom(actualReturnType.getComponentType())) {
|
||||
Class<? extends Annotation> nestedAnnotationType =
|
||||
(Class<? extends Annotation>) requiredReturnType.getComponentType();
|
||||
Map<String, Object>[] maps = (Map<String, Object>[]) attributeValue;
|
||||
attributes.put(attributeName, synthesizeAnnotationArray(maps, nestedAnnotationType));
|
||||
converted = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue