Rename SearchStrategy.EXHAUSTIVE to TYPE_HIERARCHY
Rename `SearchStrategy.EXHAUSTIVE` from `MergedAnnotations` to `SearchStrategy.TYPE_HIERARCHY` See gh-23378
This commit is contained in:
@@ -763,7 +763,7 @@ public abstract class AnnotatedElementUtils {
|
||||
}
|
||||
|
||||
private static MergedAnnotations findAnnotations(AnnotatedElement element) {
|
||||
return MergedAnnotations.from(element, SearchStrategy.EXHAUSTIVE,
|
||||
return MergedAnnotations.from(element, SearchStrategy.TYPE_HIERARCHY,
|
||||
RepeatableContainers.none(), AnnotationFilter.PLAIN);
|
||||
}
|
||||
|
||||
@@ -771,7 +771,7 @@ public abstract class AnnotatedElementUtils {
|
||||
@Nullable Class<? extends Annotation> containerType, Class<? extends Annotation> annotationType) {
|
||||
|
||||
RepeatableContainers repeatableContainers = RepeatableContainers.of(annotationType, containerType);
|
||||
return MergedAnnotations.from(element, SearchStrategy.EXHAUSTIVE,
|
||||
return MergedAnnotations.from(element, SearchStrategy.TYPE_HIERARCHY,
|
||||
repeatableContainers, AnnotationFilter.PLAIN);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class AnnotationAwareOrderComparator extends OrderComparator {
|
||||
@Nullable
|
||||
private Integer findOrderFromAnnotation(Object obj) {
|
||||
AnnotatedElement element = (obj instanceof AnnotatedElement ? (AnnotatedElement) obj : obj.getClass());
|
||||
MergedAnnotations annotations = MergedAnnotations.from(element, SearchStrategy.EXHAUSTIVE);
|
||||
MergedAnnotations annotations = MergedAnnotations.from(element, SearchStrategy.TYPE_HIERARCHY);
|
||||
Integer order = OrderUtils.getOrderFromAnnotations(element, annotations);
|
||||
if (order == null && obj instanceof DecoratingProxy) {
|
||||
return findOrderFromAnnotation(((DecoratingProxy) obj).getDecoratedClass());
|
||||
|
||||
@@ -524,7 +524,7 @@ public abstract class AnnotationUtils {
|
||||
return method.getDeclaredAnnotation(annotationType);
|
||||
}
|
||||
// Exhaustive retrieval of merged annotations...
|
||||
return MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE,
|
||||
return MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY,
|
||||
RepeatableContainers.none(), AnnotationFilter.PLAIN)
|
||||
.get(annotationType).withNonMergedAttributes()
|
||||
.synthesize(MergedAnnotation::isPresent).orElse(null);
|
||||
@@ -563,7 +563,7 @@ public abstract class AnnotationUtils {
|
||||
return clazz.getDeclaredAnnotation(annotationType);
|
||||
}
|
||||
// Exhaustive retrieval of merged annotations...
|
||||
return MergedAnnotations.from(clazz, SearchStrategy.EXHAUSTIVE,
|
||||
return MergedAnnotations.from(clazz, SearchStrategy.TYPE_HIERARCHY,
|
||||
RepeatableContainers.none(), AnnotationFilter.PLAIN)
|
||||
.get(annotationType).withNonMergedAttributes()
|
||||
.synthesize(MergedAnnotation::isPresent).orElse(null);
|
||||
|
||||
@@ -112,6 +112,7 @@ abstract class AnnotationsScanner {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SuppressWarnings("deprecation")
|
||||
private static <C, R> R processClass(C context, Class<?> source,
|
||||
SearchStrategy searchStrategy, AnnotationsProcessor<C, R> processor,
|
||||
@Nullable BiPredicate<C, Class<?>> classFilter) {
|
||||
@@ -124,6 +125,7 @@ abstract class AnnotationsScanner {
|
||||
case SUPERCLASS:
|
||||
return processClassHierarchy(context, new int[] {0}, source, processor, classFilter, false);
|
||||
case EXHAUSTIVE:
|
||||
case TYPE_HIERARCHY:
|
||||
return processClassHierarchy(context, new int[] {0}, source, processor, classFilter, true);
|
||||
}
|
||||
throw new IllegalStateException("Unsupported search strategy " + searchStrategy);
|
||||
@@ -221,6 +223,7 @@ abstract class AnnotationsScanner {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SuppressWarnings("deprecation")
|
||||
private static <C, R> R processMethod(C context, Method source,
|
||||
SearchStrategy searchStrategy, AnnotationsProcessor<C, R> processor,
|
||||
@Nullable BiPredicate<C, Class<?>> classFilter) {
|
||||
@@ -233,6 +236,7 @@ abstract class AnnotationsScanner {
|
||||
return processMethodHierarchy(context, new int[] {0}, source.getDeclaringClass(),
|
||||
processor, classFilter, source, false);
|
||||
case EXHAUSTIVE:
|
||||
case TYPE_HIERARCHY:
|
||||
return processMethodHierarchy(context, new int[] {0}, source.getDeclaringClass(),
|
||||
processor, classFilter, source, true);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ import org.springframework.lang.Nullable;
|
||||
*
|
||||
* <p>Different {@linkplain SearchStrategy search strategies} can be used to locate
|
||||
* related source elements that contain the annotations to be aggregated. For
|
||||
* example, {@link SearchStrategy#EXHAUSTIVE} will search both superclasses and
|
||||
* example, {@link SearchStrategy#TYPE_HIERARCHY} will search both superclasses and
|
||||
* implemented interfaces.
|
||||
*
|
||||
* <p>From a {@link MergedAnnotations} instance you can either
|
||||
@@ -428,8 +428,18 @@ public interface MergedAnnotations extends Iterable<MergedAnnotation<Annotation>
|
||||
* Perform a full search of all related elements, including those on any
|
||||
* superclasses or implemented interfaces. Superclass annotations do
|
||||
* not need to be meta-annotated with {@link Inherited @Inherited}.
|
||||
* @deprecated since 5.2.0.RC1 in favor of {@link #TYPE_HIERARCHY}.
|
||||
*/
|
||||
EXHAUSTIVE
|
||||
@Deprecated
|
||||
EXHAUSTIVE,
|
||||
|
||||
/**
|
||||
* Perform a full search of the entire type hierarchy , including
|
||||
* superclasses and implemented interfaces. Superclass annotations do
|
||||
* not need to be meta-annotated with {@link Inherited @Inherited}.
|
||||
*/
|
||||
TYPE_HIERARCHY
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public abstract class OrderUtils {
|
||||
*/
|
||||
@Nullable
|
||||
public static Integer getOrder(Class<?> type) {
|
||||
return getOrderFromAnnotations(type, MergedAnnotations.from(type, SearchStrategy.EXHAUSTIVE));
|
||||
return getOrderFromAnnotations(type, MergedAnnotations.from(type, SearchStrategy.TYPE_HIERARCHY));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,7 @@ public abstract class OrderUtils {
|
||||
*/
|
||||
@Nullable
|
||||
public static Integer getPriority(Class<?> type) {
|
||||
return MergedAnnotations.from(type, SearchStrategy.EXHAUSTIVE).get(JAVAX_PRIORITY_ANNOTATION)
|
||||
return MergedAnnotations.from(type, SearchStrategy.TYPE_HIERARCHY).get(JAVAX_PRIORITY_ANNOTATION)
|
||||
.getValue(MergedAnnotation.VALUE, Integer.class).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user