"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java" between
spring-framework-5.3.23.tar.gz and spring-framework-5.3.24.tar.gz

About: Spring Framework is an application framework for the Java platform and .NET Framework. Community edition.

TypeMappedAnnotation.java  (spring-framework-5.3.23):TypeMappedAnnotation.java  (spring-framework-5.3.24)
skipping to change at line 36 skipping to change at line 36
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Optional; import java.util.Optional;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
/** /**
* {@link MergedAnnotation} that adapts attributes from a root annotation by * {@link MergedAnnotation} that adapts attributes from a root annotation by
* applying the mapping and mirroring rules of an {@link AnnotationTypeMapping}. * applying the mapping and mirroring rules of an {@link AnnotationTypeMapping}.
* *
* <p>Root attribute values are extracted from a source object using a supplied * <p>Root attribute values are extracted from a source object using a supplied
* {@code BiFunction}. This allows various different annotation models to be * {@code BiFunction}. This allows various different annotation models to be
* supported by the same class. For example, the attributes source might be an * supported by the same class. For example, the attributes source might be an
* actual {@link Annotation} instance where methods on the annotation instance * actual {@link Annotation} instance where methods on the annotation instance
* are {@linkplain ReflectionUtils#invokeMethod(Method, Object) invoked} to extr * are {@linkplain AnnotationUtils#invokeAnnotationMethod(Method, Object) invoke
act d}
* values. Equally, the source could be a simple {@link Map} with values * to extract values. Similarly, the source could be a simple {@link Map} with
* extracted using {@link Map#get(Object)}. * values extracted using {@link Map#get(Object)}.
* *
* <p>Extracted root attribute values must be compatible with the attribute * <p>Extracted root attribute values must be compatible with the attribute
* return type, namely: * return type, namely:
* *
* <p><table border="1"> * <p><table border="1">
* <tr><th>Return Type</th><th>Extracted Type</th></tr> * <tr><th>Return Type</th><th>Extracted Type</th></tr>
* <tr><td>Class</td><td>Class or String</td></tr> * <tr><td>Class</td><td>Class or String</td></tr>
* <tr><td>Class[]</td><td>Class[] or String[]</td></tr> * <tr><td>Class[]</td><td>Class[] or String[]</td></tr>
* <tr><td>Annotation</td><td>Annotation, Map, or Object compatible with the val ue * <tr><td>Annotation</td><td>Annotation, Map, or Object compatible with the val ue
* extractor</td></tr> * extractor</td></tr>
skipping to change at line 434 skipping to change at line 433
} }
@Nullable @Nullable
private Object getValueFromMetaAnnotation(int attributeIndex, boolean for MirrorResolution) { private Object getValueFromMetaAnnotation(int attributeIndex, boolean for MirrorResolution) {
Object value = null; Object value = null;
if (this.useMergedValues || forMirrorResolution) { if (this.useMergedValues || forMirrorResolution) {
value = this.mapping.getMappedAnnotationValue(attributeIn dex, forMirrorResolution); value = this.mapping.getMappedAnnotationValue(attributeIn dex, forMirrorResolution);
} }
if (value == null) { if (value == null) {
Method attribute = this.mapping.getAttributes().get(attri buteIndex); Method attribute = this.mapping.getAttributes().get(attri buteIndex);
value = ReflectionUtils.invokeMethod(attribute, this.mapp ing.getAnnotation()); value = AnnotationUtils.invokeAnnotationMethod(attribute, this.mapping.getAnnotation());
} }
return value; return value;
} }
@Nullable @Nullable
private Object getValueForMirrorResolution(Method attribute, Object annot ation) { private Object getValueForMirrorResolution(Method attribute, Object annot ation) {
int attributeIndex = this.mapping.getAttributes().indexOf(attribu te); int attributeIndex = this.mapping.getAttributes().indexOf(attribu te);
boolean valueAttribute = VALUE.equals(attribute.getName()); boolean valueAttribute = VALUE.equals(attribute.getName());
return getValue(attributeIndex, !valueAttribute, true); return getValue(attributeIndex, !valueAttribute, true);
} }
skipping to change at line 555 skipping to change at line 554
if (value instanceof MergedAnnotation) { if (value instanceof MergedAnnotation) {
return (MergedAnnotation<?>) value; return (MergedAnnotation<?>) value;
} }
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotat ionType(annotationType).get(0); AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotat ionType(annotationType).get(0);
return new TypeMappedAnnotation<>( return new TypeMappedAnnotation<>(
mapping, null, this.source, value, getValueExtrac tor(value), this.aggregateIndex); mapping, null, this.source, value, getValueExtrac tor(value), this.aggregateIndex);
} }
private ValueExtractor getValueExtractor(Object value) { private ValueExtractor getValueExtractor(Object value) {
if (value instanceof Annotation) { if (value instanceof Annotation) {
return ReflectionUtils::invokeMethod; return AnnotationUtils::invokeAnnotationMethod;
} }
if (value instanceof Map) { if (value instanceof Map) {
return TypeMappedAnnotation::extractFromMap; return TypeMappedAnnotation::extractFromMap;
} }
return this.valueExtractor; return this.valueExtractor;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private <T> Class<T> getAdaptType(Method attribute, Class<T> type) { private <T> Class<T> getAdaptType(Method attribute, Class<T> type) {
if (type != Object.class) { if (type != Object.class) {
skipping to change at line 614 skipping to change at line 613
if (this.source instanceof Member) { if (this.source instanceof Member) {
((Member) this.source).getDeclaringClass().getCla ssLoader(); ((Member) this.source).getDeclaringClass().getCla ssLoader();
} }
} }
return null; return null;
} }
static <A extends Annotation> MergedAnnotation<A> from(@Nullable Object s ource, A annotation) { static <A extends Annotation> MergedAnnotation<A> from(@Nullable Object s ource, A annotation) {
Assert.notNull(annotation, "Annotation must not be null"); Assert.notNull(annotation, "Annotation must not be null");
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnot ationType(annotation.annotationType()); AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnot ationType(annotation.annotationType());
return new TypeMappedAnnotation<>(mappings.get(0), null, source, return new TypeMappedAnnotation<>(
annotation, ReflectionUtils::invokeMethod, 0); mappings.get(0), null, source, annotation, Annota
tionUtils::invokeAnnotationMethod, 0);
} }
static <A extends Annotation> MergedAnnotation<A> of( static <A extends Annotation> MergedAnnotation<A> of(
@Nullable ClassLoader classLoader, @Nullable Object sourc e, @Nullable ClassLoader classLoader, @Nullable Object sourc e,
Class<A> annotationType, @Nullable Map<String, ?> attribu tes) { Class<A> annotationType, @Nullable Map<String, ?> attribu tes) {
Assert.notNull(annotationType, "Annotation type must not be null" ); Assert.notNull(annotationType, "Annotation type must not be null" );
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnot ationType(annotationType); AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnot ationType(annotationType);
return new TypeMappedAnnotation<>( return new TypeMappedAnnotation<>(
mappings.get(0), classLoader, source, attributes, TypeMappedAnnotation::extractFromMap, 0); mappings.get(0), classLoader, source, attributes, TypeMappedAnnotation::extractFromMap, 0);
skipping to change at line 648 skipping to change at line 648
return createIfPossible(mapping, annotation.getSource(), annotati on.synthesize(), return createIfPossible(mapping, annotation.getSource(), annotati on.synthesize(),
annotation.getAggregateIndex(), logger); annotation.getAggregateIndex(), logger);
} }
@Nullable @Nullable
static <A extends Annotation> TypeMappedAnnotation<A> createIfPossible( static <A extends Annotation> TypeMappedAnnotation<A> createIfPossible(
AnnotationTypeMapping mapping, @Nullable Object source, A nnotation annotation, AnnotationTypeMapping mapping, @Nullable Object source, A nnotation annotation,
int aggregateIndex, IntrospectionFailureLogger logger) { int aggregateIndex, IntrospectionFailureLogger logger) {
return createIfPossible(mapping, source, annotation, return createIfPossible(mapping, source, annotation,
ReflectionUtils::invokeMethod, aggregateIndex, lo gger); AnnotationUtils::invokeAnnotationMethod, aggregat eIndex, logger);
} }
@Nullable @Nullable
private static <A extends Annotation> TypeMappedAnnotation<A> createIfPos sible( private static <A extends Annotation> TypeMappedAnnotation<A> createIfPos sible(
AnnotationTypeMapping mapping, @Nullable Object source, @ Nullable Object rootAttribute, AnnotationTypeMapping mapping, @Nullable Object source, @ Nullable Object rootAttribute,
ValueExtractor valueExtractor, int aggregateIndex, Intros pectionFailureLogger logger) { ValueExtractor valueExtractor, int aggregateIndex, Intros pectionFailureLogger logger) {
try { try {
return new TypeMappedAnnotation<>(mapping, null, source, rootAttribute, return new TypeMappedAnnotation<>(mapping, null, source, rootAttribute,
valueExtractor, aggregateIndex); valueExtractor, aggregateIndex);
 End of changes. 6 change blocks. 
10 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)