public class AnnotatedElementUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static interface |
AnnotatedElementUtils.Processor<T>
Callback interface used to process an annotation.
|
Constructor and Description |
---|
AnnotatedElementUtils() |
Modifier and Type | Method and Description |
---|---|
private static <T> T |
doProcess(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationType,
boolean traverseClassHierarchy,
AnnotatedElementUtils.Processor<T> processor,
java.util.Set<java.lang.reflect.AnnotatedElement> visited,
int metaDepth)
Perform the search algorithm for the
process(java.lang.reflect.AnnotatedElement, java.lang.String, boolean, org.springframework.core.annotation.AnnotatedElementUtils.Processor<T>) method, avoiding
endless recursion by tracking which annotated elements have already been
visited. |
static MultiValueMap<java.lang.String,java.lang.Object> |
getAllAnnotationAttributes(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationType) |
static MultiValueMap<java.lang.String,java.lang.Object> |
getAllAnnotationAttributes(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationType,
boolean classValuesAsString,
boolean nestedAnnotationsAsMap) |
static AnnotationAttributes |
getAnnotationAttributes(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationType) |
static AnnotationAttributes |
getAnnotationAttributes(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationType,
boolean classValuesAsString,
boolean nestedAnnotationsAsMap) |
static java.util.Set<java.lang.String> |
getMetaAnnotationTypes(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationType) |
static boolean |
hasMetaAnnotationTypes(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationType) |
static boolean |
isAnnotated(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationType) |
private static <T> T |
process(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationType,
boolean traverseClassHierarchy,
AnnotatedElementUtils.Processor<T> processor)
Process all annotations of the specified
annotationType and
recursively all meta-annotations on the specified element . |
public static java.util.Set<java.lang.String> getMetaAnnotationTypes(java.lang.reflect.AnnotatedElement element, java.lang.String annotationType)
public static boolean hasMetaAnnotationTypes(java.lang.reflect.AnnotatedElement element, java.lang.String annotationType)
public static boolean isAnnotated(java.lang.reflect.AnnotatedElement element, java.lang.String annotationType)
public static AnnotationAttributes getAnnotationAttributes(java.lang.reflect.AnnotatedElement element, java.lang.String annotationType)
public static AnnotationAttributes getAnnotationAttributes(java.lang.reflect.AnnotatedElement element, java.lang.String annotationType, boolean classValuesAsString, boolean nestedAnnotationsAsMap)
public static MultiValueMap<java.lang.String,java.lang.Object> getAllAnnotationAttributes(java.lang.reflect.AnnotatedElement element, java.lang.String annotationType)
public static MultiValueMap<java.lang.String,java.lang.Object> getAllAnnotationAttributes(java.lang.reflect.AnnotatedElement element, java.lang.String annotationType, boolean classValuesAsString, boolean nestedAnnotationsAsMap)
private static <T> T process(java.lang.reflect.AnnotatedElement element, java.lang.String annotationType, boolean traverseClassHierarchy, AnnotatedElementUtils.Processor<T> processor)
annotationType
and
recursively all meta-annotations on the specified element
.
If the traverseClassHierarchy
flag is true
and the sought
annotation is neither directly present on the given element nor
present on the given element as a meta-annotation, then the algorithm will
recursively search through the class hierarchy of the given element.
element
- the annotated elementannotationType
- the annotation type to findtraverseClassHierarchy
- whether or not to traverse up the class
hierarchy recursivelyprocessor
- the processor to delegate toprivate static <T> T doProcess(java.lang.reflect.AnnotatedElement element, java.lang.String annotationType, boolean traverseClassHierarchy, AnnotatedElementUtils.Processor<T> processor, java.util.Set<java.lang.reflect.AnnotatedElement> visited, int metaDepth)
process(java.lang.reflect.AnnotatedElement, java.lang.String, boolean, org.springframework.core.annotation.AnnotatedElementUtils.Processor<T>)
method, avoiding
endless recursion by tracking which annotated elements have already been
visited.
The metaDepth
parameter represents the depth of the annotation
relative to the initial element. For example, an annotation that is
present on the element will have a depth of 0; a meta-annotation
will have a depth of 1; and a meta-meta-annotation will have a depth of 2.
element
- the annotated elementannotationType
- the annotation type to findtraverseClassHierarchy
- whether or not to traverse up the class
hierarchy recursivelyprocessor
- the processor to delegate tovisited
- the set of annotated elements that have already been visitedmetaDepth
- the depth of the annotation relative to the initial element