AnnotationTypeMapping.java (spring-framework-5.3.23) | : | AnnotationTypeMapping.java (spring-framework-5.3.24) | ||
---|---|---|---|---|
skipping to change at line 35 | skipping to change at line 35 | |||
import java.util.HashMap; | import java.util.HashMap; | |||
import java.util.HashSet; | import java.util.HashSet; | |||
import java.util.LinkedHashSet; | import java.util.LinkedHashSet; | |||
import java.util.List; | import java.util.List; | |||
import java.util.Map; | import java.util.Map; | |||
import java.util.Set; | import java.util.Set; | |||
import org.springframework.core.annotation.AnnotationTypeMapping.MirrorSets.Mirr orSet; | import org.springframework.core.annotation.AnnotationTypeMapping.MirrorSets.Mirr orSet; | |||
import org.springframework.lang.Nullable; | import org.springframework.lang.Nullable; | |||
import org.springframework.util.ObjectUtils; | import org.springframework.util.ObjectUtils; | |||
import org.springframework.util.ReflectionUtils; | ||||
import org.springframework.util.StringUtils; | import org.springframework.util.StringUtils; | |||
/** | /** | |||
* Provides mapping information for a single annotation (or meta-annotation) in | * Provides mapping information for a single annotation (or meta-annotation) in | |||
* the context of a root annotation type. | * the context of a root annotation type. | |||
* | * | |||
* @author Phillip Webb | * @author Phillip Webb | |||
* @author Sam Brannen | * @author Sam Brannen | |||
* @since 5.2 | * @since 5.2 | |||
* @see AnnotationTypeMappings | * @see AnnotationTypeMappings | |||
skipping to change at line 241 | skipping to change at line 240 | |||
for (int i = 0; i < mapping.attributes.size(); i+ +) { | for (int i = 0; i < mapping.attributes.size(); i+ +) { | |||
if (aliases.contains(mapping.attributes.g et(i))) { | if (aliases.contains(mapping.attributes.g et(i))) { | |||
mapping.aliasMappings[i] = rootAt tributeIndex; | mapping.aliasMappings[i] = rootAt tributeIndex; | |||
} | } | |||
} | } | |||
} | } | |||
mapping.mirrorSets.updateFrom(aliases); | mapping.mirrorSets.updateFrom(aliases); | |||
mapping.claimedAliases.addAll(aliases); | mapping.claimedAliases.addAll(aliases); | |||
if (mapping.annotation != null) { | if (mapping.annotation != null) { | |||
int[] resolvedMirrors = mapping.mirrorSets.resolv e(null, | int[] resolvedMirrors = mapping.mirrorSets.resolv e(null, | |||
mapping.annotation, ReflectionUti ls::invokeMethod); | mapping.annotation, AnnotationUti ls::invokeAnnotationMethod); | |||
for (int i = 0; i < mapping.attributes.size(); i+ +) { | for (int i = 0; i < mapping.attributes.size(); i+ +) { | |||
if (aliases.contains(mapping.attributes.g et(i))) { | if (aliases.contains(mapping.attributes.g et(i))) { | |||
this.annotationValueMappings[attr ibuteIndex] = resolvedMirrors[i]; | this.annotationValueMappings[attr ibuteIndex] = resolvedMirrors[i]; | |||
this.annotationValueSource[attrib uteIndex] = mapping; | this.annotationValueSource[attrib uteIndex] = mapping; | |||
} | } | |||
} | } | |||
} | } | |||
mapping = mapping.source; | mapping = mapping.source; | |||
} | } | |||
} | } | |||
skipping to change at line 505 | skipping to change at line 504 | |||
@Nullable | @Nullable | |||
Object getMappedAnnotationValue(int attributeIndex, boolean metaAnnotatio nsOnly) { | Object getMappedAnnotationValue(int attributeIndex, boolean metaAnnotatio nsOnly) { | |||
int mappedIndex = this.annotationValueMappings[attributeIndex]; | int mappedIndex = this.annotationValueMappings[attributeIndex]; | |||
if (mappedIndex == -1) { | if (mappedIndex == -1) { | |||
return null; | return null; | |||
} | } | |||
AnnotationTypeMapping source = this.annotationValueSource[attribu teIndex]; | AnnotationTypeMapping source = this.annotationValueSource[attribu teIndex]; | |||
if (source == this && metaAnnotationsOnly) { | if (source == this && metaAnnotationsOnly) { | |||
return null; | return null; | |||
} | } | |||
return ReflectionUtils.invokeMethod(source.attributes.get(mappedI ndex), source.annotation); | return AnnotationUtils.invokeAnnotationMethod(source.attributes.g et(mappedIndex), source.annotation); | |||
} | } | |||
/** | /** | |||
* Determine if the specified value is equivalent to the default value of the | * Determine if the specified value is equivalent to the default value of the | |||
* attribute at the given index. | * attribute at the given index. | |||
* @param attributeIndex the attribute index of the source attribute | * @param attributeIndex the attribute index of the source attribute | |||
* @param value the value to check | * @param value the value to check | |||
* @param valueExtractor the value extractor used to extract values from any | * @param valueExtractor the value extractor used to extract values from any | |||
* nested annotations | * nested annotations | |||
* @return {@code true} if the value is equivalent to the default value | * @return {@code true} if the value is equivalent to the default value | |||
skipping to change at line 593 | skipping to change at line 592 | |||
private static boolean areEquivalent(Class<?> value, String extractedValu e) { | private static boolean areEquivalent(Class<?> value, String extractedValu e) { | |||
return value.getName().equals(extractedValue); | return value.getName().equals(extractedValue); | |||
} | } | |||
private static boolean areEquivalent(Annotation annotation, @Nullable Obj ect extractedValue, | private static boolean areEquivalent(Annotation annotation, @Nullable Obj ect extractedValue, | |||
ValueExtractor valueExtractor) { | ValueExtractor valueExtractor) { | |||
AttributeMethods attributes = AttributeMethods.forAnnotationType( annotation.annotationType()); | AttributeMethods attributes = AttributeMethods.forAnnotationType( annotation.annotationType()); | |||
for (int i = 0; i < attributes.size(); i++) { | for (int i = 0; i < attributes.size(); i++) { | |||
Method attribute = attributes.get(i); | Method attribute = attributes.get(i); | |||
Object value1 = ReflectionUtils.invokeMethod(attribute, a nnotation); | Object value1 = AnnotationUtils.invokeAnnotationMethod(at tribute, annotation); | |||
Object value2; | Object value2; | |||
if (extractedValue instanceof TypeMappedAnnotation) { | if (extractedValue instanceof TypeMappedAnnotation) { | |||
value2 = ((TypeMappedAnnotation<?>) extractedValu e).getValue(attribute.getName()).orElse(null); | value2 = ((TypeMappedAnnotation<?>) extractedValu e).getValue(attribute.getName()).orElse(null); | |||
} | } | |||
else { | else { | |||
value2 = valueExtractor.extract(attribute, extrac tedValue); | value2 = valueExtractor.extract(attribute, extrac tedValue); | |||
} | } | |||
if (!areEquivalent(value1, value2, valueExtractor)) { | if (!areEquivalent(value1, value2, valueExtractor)) { | |||
return false; | return false; | |||
} | } | |||
End of changes. 4 change blocks. | ||||
4 lines changed or deleted | 3 lines changed or added |