From e56363737baa529fc4fa51b02bf2b73ca9d9f4f9 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 2 May 2015 10:38:31 +0200 Subject: [PATCH] Make findAnnotationAttributes power search private --- .../annotation/AnnotatedElementUtils.java | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java index 7844bfc267..e4554b24e6 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java @@ -176,9 +176,10 @@ public class AnnotatedElementUtils { * in the annotation hierarchy of the supplied {@link AnnotatedElement}, * and merge the results into an {@link AnnotationAttributes} map. * - *

Delegates to - * {@link #findAnnotationAttributes(AnnotatedElement, String, boolean, boolean, boolean, boolean, boolean, boolean)}, - * supplying {@code true} for all {@code search*} flags. + *

If the annotated element is a class, this algorithm will additionally + * search on interfaces and superclasses. + *

If the annotated element is a method, this algorithm will additionally + * search on methods in interfaces and superclasses. * * @param element the annotated element; never {@code null} * @param annotationType the annotation type to find; never {@code null} @@ -196,9 +197,10 @@ public class AnnotatedElementUtils { * in the annotation hierarchy of the supplied {@link AnnotatedElement}, * and merge the results into an {@link AnnotationAttributes} map. * - *

Delegates to - * {@link #findAnnotationAttributes(AnnotatedElement, String, boolean, boolean, boolean, boolean, boolean, boolean)}, - * supplying {@code true} for all {@code search*} flags. + *

If the annotated element is a class, this algorithm will additionally + * search on interfaces and superclasses. + *

If the annotated element is a method, this algorithm will additionally + * search on methods in interfaces and superclasses. * * @param element the annotated element; never {@code null} * @param annotationType the fully qualified class name of the annotation @@ -210,6 +212,33 @@ public class AnnotatedElementUtils { return findAnnotationAttributes(element, annotationType, true, true, true, true, false, false); } + /** + * Find annotation attributes of the specified {@code annotationType} + * in the annotation hierarchy of the supplied {@link AnnotatedElement}, + * and merge the results into an {@link AnnotationAttributes} map. + * + *

If the annotated element is a class, this algorithm will additionally + * search on interfaces and superclasses. + *

If the annotated element is a method, this algorithm will additionally + * search on methods in interfaces and superclasses. + * + * @param element the annotated element; never {@code null} + * @param annotationType the fully qualified class name of the annotation + * type to find; never {@code null} or empty + * @param classValuesAsString whether to convert Class references into + * Strings or to preserve them as Class references + * @param nestedAnnotationsAsMap whether to convert nested Annotation + * instances into {@link AnnotationAttributes} maps or to preserve them + * as Annotation instances + * @return the merged {@code AnnotationAttributes}, or {@code null} if + * not found + */ + public static AnnotationAttributes findAnnotationAttributes(AnnotatedElement element, String annotationType, + boolean classValuesAsString, boolean nestedAnnotationsAsMap) { + return findAnnotationAttributes(element, annotationType, true, true, true, true, classValuesAsString, + nestedAnnotationsAsMap); + } + /** * Find annotation attributes of the specified {@code annotationType} * in the annotation hierarchy of the supplied {@link AnnotatedElement}, @@ -234,7 +263,7 @@ public class AnnotatedElementUtils { * @return the merged {@code AnnotationAttributes}, or {@code null} if * not found */ - public static AnnotationAttributes findAnnotationAttributes(AnnotatedElement element, String annotationType, + private static AnnotationAttributes findAnnotationAttributes(AnnotatedElement element, String annotationType, boolean searchOnInterfaces, boolean searchOnSuperclasses, boolean searchOnMethodsInInterfaces, boolean searchOnMethodsInSuperclasses, boolean classValuesAsString, boolean nestedAnnotationsAsMap) {