public class AnnotatedElementUtils
extends java.lang.Object
AnnotatedElements
.
AnnotatedElementUtils
defines the public API for Spring's
meta-annotation programming model with support for annotation attribute
overrides. If you do not need support for annotation attribute
overrides, consider using AnnotationUtils
instead.
Note that the features of this class are not provided by the JDK's introspection facilities themselves.
Support for meta-annotations with attribute overrides in
composed annotations is provided by all variants of the
getMergedAnnotationAttributes()
, getMergedAnnotation()
,
findMergedAnnotationAttributes()
, and findMergedAnnotation()
methods.
The search algorithms used by methods in this class follow either find or get semantics. Consult the javadocs for each individual method for details on which search algorithm is used.
Get semantics are limited to searching for annotations
that are either present on an AnnotatedElement
(i.e.,
declared locally or inherited)
or declared within the annotation hierarchy above the
AnnotatedElement
.
Find semantics are much more exhaustive, providing get semantics plus support for the following:
@Inherited
Methods following get semantics will honor the contract of
Java's @Inherited
annotation except
that locally declared annotations (including custom composed annotations)
will be favored over inherited annotations. In contrast, methods following
find semantics will completely ignore the presence of
@Inherited
since the find search algorithm manually
traverses type and method hierarchies and thereby implicitly supports
annotation inheritance without the need for @Inherited
.
AliasFor
,
AnnotationAttributes
,
AnnotationUtils
,
BridgeMethodResolver
Modifier and Type | Class and Description |
---|---|
private static class |
AnnotatedElementUtils.MergedAnnotationAttributesProcessor
AnnotatedElementUtils.Processor that gets the AnnotationAttributes for the
target annotation during the AnnotatedElementUtils.MergedAnnotationAttributesProcessor.process(java.lang.reflect.AnnotatedElement, java.lang.annotation.Annotation, int) phase and then merges
annotation attributes from lower levels in the annotation hierarchy
during the AnnotatedElementUtils.MergedAnnotationAttributesProcessor.postProcess(java.lang.reflect.AnnotatedElement, java.lang.annotation.Annotation, org.springframework.core.annotation.AnnotationAttributes) phase. |
private static interface |
AnnotatedElementUtils.Processor<T>
Callback interface that is used to process annotations during a search.
|
private static class |
AnnotatedElementUtils.SimpleAnnotationProcessor<T>
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.Boolean |
CONTINUE |
Constructor and Description |
---|
AnnotatedElementUtils() |
Modifier and Type | Method and Description |
---|---|
static <A extends java.lang.annotation.Annotation> |
findMergedAnnotation(java.lang.reflect.AnnotatedElement element,
java.lang.Class<A> annotationType)
Find the first annotation of the specified
annotationType within
the annotation hierarchy above the supplied element ,
merge that annotation's attributes with matching attributes from
annotations in lower levels of the annotation hierarchy, and synthesize
the result back into an annotation of the specified annotationType . |
static <A extends java.lang.annotation.Annotation> |
findMergedAnnotation(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationName)
Deprecated.
As of Spring Framework 4.2.3, use
findMergedAnnotation(AnnotatedElement, Class) instead. |
static AnnotationAttributes |
findMergedAnnotationAttributes(java.lang.reflect.AnnotatedElement element,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
boolean classValuesAsString,
boolean nestedAnnotationsAsMap)
Find the first annotation of the specified
annotationName within
the annotation hierarchy above the supplied element and
merge that annotation's attributes with matching attributes from
annotations in lower levels of the annotation hierarchy. |
static AnnotationAttributes |
findMergedAnnotationAttributes(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationName,
boolean classValuesAsString,
boolean nestedAnnotationsAsMap)
Find the first annotation of the specified
annotationName within
the annotation hierarchy above the supplied element and
merge that annotation's attributes with matching attributes from
annotations in lower levels of the annotation hierarchy. |
static MultiValueMap<java.lang.String,java.lang.Object> |
getAllAnnotationAttributes(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationName)
Get the annotation attributes of all annotations of the specified
annotationName in the annotation hierarchy above the supplied
AnnotatedElement and store the results in a MultiValueMap . |
static MultiValueMap<java.lang.String,java.lang.Object> |
getAllAnnotationAttributes(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationName,
boolean classValuesAsString,
boolean nestedAnnotationsAsMap)
Get the annotation attributes of all annotations of
the specified
annotationName in the annotation hierarchy above
the supplied AnnotatedElement and store the results in a
MultiValueMap . |
static AnnotationAttributes |
getAnnotationAttributes(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationName)
Deprecated.
As of Spring Framework 4.2, use
getMergedAnnotationAttributes(AnnotatedElement, String) instead. |
static AnnotationAttributes |
getAnnotationAttributes(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationName,
boolean classValuesAsString,
boolean nestedAnnotationsAsMap)
Deprecated.
As of Spring Framework 4.2, use
getMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean) instead. |
static <A extends java.lang.annotation.Annotation> |
getMergedAnnotation(java.lang.reflect.AnnotatedElement element,
java.lang.Class<A> annotationType)
Get the first annotation of the specified
annotationType within
the annotation hierarchy above the supplied element ,
merge that annotation's attributes with matching attributes from
annotations in lower levels of the annotation hierarchy, and synthesize
the result back into an annotation of the specified annotationType . |
static AnnotationAttributes |
getMergedAnnotationAttributes(java.lang.reflect.AnnotatedElement element,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Get the first annotation of the specified
annotationType within
the annotation hierarchy above the supplied element and
merge that annotation's attributes with matching attributes from
annotations in lower levels of the annotation hierarchy. |
static AnnotationAttributes |
getMergedAnnotationAttributes(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationName)
Get the first annotation of the specified
annotationName within
the annotation hierarchy above the supplied element and
merge that annotation's attributes with matching attributes from
annotations in lower levels of the annotation hierarchy. |
static AnnotationAttributes |
getMergedAnnotationAttributes(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationName,
boolean classValuesAsString,
boolean nestedAnnotationsAsMap)
Get the first annotation of the specified
annotationName within
the annotation hierarchy above the supplied element and
merge that annotation's attributes with matching attributes from
annotations in lower levels of the annotation hierarchy. |
static java.util.Set<java.lang.String> |
getMetaAnnotationTypes(java.lang.reflect.AnnotatedElement element,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Get the fully qualified class names of all meta-annotation types
present on the annotation (of the specified
annotationType )
on the supplied AnnotatedElement . |
static java.util.Set<java.lang.String> |
getMetaAnnotationTypes(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationName)
Get the fully qualified class names of all meta-annotation
types present on the annotation (of the specified
annotationName ) on the supplied AnnotatedElement . |
static boolean |
hasMetaAnnotationTypes(java.lang.reflect.AnnotatedElement element,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Determine if the supplied
AnnotatedElement is annotated with
a composed annotation that is meta-annotated with an
annotation of the specified annotationName . |
static boolean |
hasMetaAnnotationTypes(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationName)
Determine if the supplied
AnnotatedElement is annotated with a
composed annotation that is meta-annotated with an annotation
of the specified annotationName . |
static boolean |
isAnnotated(java.lang.reflect.AnnotatedElement element,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Determine if an annotation of the specified
annotationName
is present on the supplied AnnotatedElement or
within the annotation hierarchy above the specified element. |
static boolean |
isAnnotated(java.lang.reflect.AnnotatedElement element,
java.lang.String annotationName)
Determine if an annotation of the specified
annotationName is
present on the supplied AnnotatedElement or within the
annotation hierarchy above the specified element. |
private static <T> T |
searchOnInterfaces(java.lang.reflect.Method method,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
java.lang.String annotationName,
AnnotatedElementUtils.Processor<T> processor,
java.util.Set<java.lang.reflect.AnnotatedElement> visited,
int metaDepth,
java.lang.Class<?>[] ifcs) |
private static <T> T |
searchWithFindSemantics(java.lang.reflect.AnnotatedElement element,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
java.lang.String annotationName,
AnnotatedElementUtils.Processor<T> processor)
Search for annotations of the specified
annotationName on
the specified element , following find semantics. |
private static <T> T |
searchWithFindSemantics(java.lang.reflect.AnnotatedElement element,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
java.lang.String annotationName,
AnnotatedElementUtils.Processor<T> processor,
java.util.Set<java.lang.reflect.AnnotatedElement> visited,
int metaDepth)
Perform the search algorithm for the
searchWithFindSemantics(java.lang.reflect.AnnotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation>, java.lang.String, org.springframework.core.annotation.AnnotatedElementUtils.Processor<T>)
method, avoiding endless recursion by tracking which annotated elements
have already been visited. |
private static <T> T |
searchWithGetSemantics(java.lang.reflect.AnnotatedElement element,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
java.lang.String annotationName,
AnnotatedElementUtils.Processor<T> processor)
Search for annotations of the specified
annotationName on
the specified element , following get semantics. |
private static <T> T |
searchWithGetSemantics(java.lang.reflect.AnnotatedElement element,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
java.lang.String annotationName,
AnnotatedElementUtils.Processor<T> processor,
java.util.Set<java.lang.reflect.AnnotatedElement> visited,
int metaDepth)
Perform the search algorithm for the
searchWithGetSemantics(java.lang.reflect.AnnotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation>, java.lang.String, org.springframework.core.annotation.AnnotatedElementUtils.Processor<T>)
method, avoiding endless recursion by tracking which annotated elements
have already been visited. |
private static <T> T |
searchWithGetSemanticsInAnnotations(java.lang.reflect.AnnotatedElement annotatedElement,
java.util.List<java.lang.annotation.Annotation> annotations,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
java.lang.String annotationName,
AnnotatedElementUtils.Processor<T> processor,
java.util.Set<java.lang.reflect.AnnotatedElement> visited,
int metaDepth)
This method is invoked by
searchWithGetSemantics(AnnotatedElement, Class, String, Processor, Set, int)
to perform the actual search within the supplied list of annotations. |
public static java.util.Set<java.lang.String> getMetaAnnotationTypes(java.lang.reflect.AnnotatedElement element, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
annotationType
)
on the supplied AnnotatedElement
.
This method follows get semantics as described in the class-level javadoc.
element
- the annotated elementannotationType
- the annotation type on which to find meta-annotationsnull
if not foundgetMetaAnnotationTypes(AnnotatedElement, String)
,
hasMetaAnnotationTypes(java.lang.reflect.AnnotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation>)
public static java.util.Set<java.lang.String> getMetaAnnotationTypes(java.lang.reflect.AnnotatedElement element, java.lang.String annotationName)
annotationName
) on the supplied AnnotatedElement
.
This method follows get semantics as described in the class-level javadoc.
element
- the annotated elementannotationName
- the fully qualified class name of the annotation
type on which to find meta-annotationsnull
if not foundgetMetaAnnotationTypes(AnnotatedElement, Class)
,
hasMetaAnnotationTypes(java.lang.reflect.AnnotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation>)
public static boolean hasMetaAnnotationTypes(java.lang.reflect.AnnotatedElement element, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
AnnotatedElement
is annotated with
a composed annotation that is meta-annotated with an
annotation of the specified annotationName
.
This method follows get semantics as described in the class-level javadoc.
element
- the annotated elementannotationType
- the annotation type on which to find meta-annotationstrue
if a matching meta-annotation is presentgetMetaAnnotationTypes(java.lang.reflect.AnnotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation>)
public static boolean hasMetaAnnotationTypes(java.lang.reflect.AnnotatedElement element, java.lang.String annotationName)
AnnotatedElement
is annotated with a
composed annotation that is meta-annotated with an annotation
of the specified annotationName
.
This method follows get semantics as described in the class-level javadoc.
element
- the annotated elementannotationName
- the fully qualified class name of the
meta-annotation type to findtrue
if a matching meta-annotation is presentgetMetaAnnotationTypes(java.lang.reflect.AnnotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation>)
public static boolean isAnnotated(java.lang.reflect.AnnotatedElement element, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
annotationName
is present on the supplied AnnotatedElement
or
within the annotation hierarchy above the specified element.
If this method returns true
, then getMergedAnnotationAttributes(java.lang.reflect.AnnotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation>)
will return a non-null value.
This method follows get semantics as described in the class-level javadoc.
element
- the annotated elementannotationType
- the annotation type on which to find meta-annotationstrue
if a matching annotation is presentpublic static boolean isAnnotated(java.lang.reflect.AnnotatedElement element, java.lang.String annotationName)
annotationName
is
present on the supplied AnnotatedElement
or within the
annotation hierarchy above the specified element.
If this method returns true
, then getMergedAnnotationAttributes(java.lang.reflect.AnnotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation>)
will return a non-null value.
This method follows get semantics as described in the class-level javadoc.
element
- the annotated elementannotationName
- the fully qualified class name of the annotation type to findtrue
if a matching annotation is presentpublic static <A extends java.lang.annotation.Annotation> A getMergedAnnotation(java.lang.reflect.AnnotatedElement element, java.lang.Class<A> annotationType)
annotationType
within
the annotation hierarchy above the supplied element
,
merge that annotation's attributes with matching attributes from
annotations in lower levels of the annotation hierarchy, and synthesize
the result back into an annotation of the specified annotationType
.
@AliasFor
semantics are fully supported, both
within a single annotation and within the annotation hierarchy.
This method delegates to getMergedAnnotationAttributes(AnnotatedElement, Class)
and AnnotationUtils.synthesizeAnnotation(Map, Class, AnnotatedElement)
.
element
- the annotated elementannotationType
- the annotation type to findAnnotation
, or null
if not foundgetMergedAnnotationAttributes(AnnotatedElement, Class)
,
findMergedAnnotation(AnnotatedElement, Class)
,
AnnotationUtils.synthesizeAnnotation(Map, Class, AnnotatedElement)
public static AnnotationAttributes getMergedAnnotationAttributes(java.lang.reflect.AnnotatedElement element, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
annotationType
within
the annotation hierarchy above the supplied element
and
merge that annotation's attributes with matching attributes from
annotations in lower levels of the annotation hierarchy.
@AliasFor
semantics are fully supported, both
within a single annotation and within the annotation hierarchy.
This method delegates to getMergedAnnotationAttributes(AnnotatedElement, String)
.
element
- the annotated elementannotationType
- the annotation type to findAnnotationAttributes
, or null
if not foundgetMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
,
findMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
,
getMergedAnnotation(AnnotatedElement, Class)
,
findMergedAnnotation(AnnotatedElement, Class)
public static AnnotationAttributes getMergedAnnotationAttributes(java.lang.reflect.AnnotatedElement element, java.lang.String annotationName)
annotationName
within
the annotation hierarchy above the supplied element
and
merge that annotation's attributes with matching attributes from
annotations in lower levels of the annotation hierarchy.
@AliasFor
semantics are fully supported, both
within a single annotation and within the annotation hierarchy.
This method delegates to getMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
,
supplying false
for classValuesAsString
and nestedAnnotationsAsMap
.
element
- the annotated elementannotationName
- the fully qualified class name of the annotation type to findAnnotationAttributes
, or null
if not foundgetMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
,
findMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
,
findMergedAnnotation(AnnotatedElement, Class)
,
getAllAnnotationAttributes(AnnotatedElement, String)
public static AnnotationAttributes getMergedAnnotationAttributes(java.lang.reflect.AnnotatedElement element, java.lang.String annotationName, boolean classValuesAsString, boolean nestedAnnotationsAsMap)
annotationName
within
the annotation hierarchy above the supplied element
and
merge that annotation's attributes with matching attributes from
annotations in lower levels of the annotation hierarchy.
Attributes from lower levels in the annotation hierarchy override attributes
of the same name from higher levels, and @AliasFor
semantics are
fully supported, both within a single annotation and within the annotation hierarchy.
In contrast to getAllAnnotationAttributes(java.lang.reflect.AnnotatedElement, java.lang.String)
, the search algorithm used by
this method will stop searching the annotation hierarchy once the first annotation
of the specified annotationName
has been found. As a consequence,
additional annotations of the specified annotationName
will be ignored.
This method follows get semantics as described in the class-level javadoc.
element
- the annotated elementannotationName
- the fully qualified class name of the annotation type to findclassValuesAsString
- whether to convert Class references into Strings or to
preserve them as Class referencesnestedAnnotationsAsMap
- whether to convert nested Annotation instances
into AnnotationAttributes
maps or to preserve them as Annotation instancesAnnotationAttributes
, or null
if not foundfindMergedAnnotation(AnnotatedElement, Class)
,
findMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
,
getAllAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
public static <A extends java.lang.annotation.Annotation> A findMergedAnnotation(java.lang.reflect.AnnotatedElement element, java.lang.Class<A> annotationType)
annotationType
within
the annotation hierarchy above the supplied element
,
merge that annotation's attributes with matching attributes from
annotations in lower levels of the annotation hierarchy, and synthesize
the result back into an annotation of the specified annotationType
.
@AliasFor
semantics are fully supported, both
within a single annotation and within the annotation hierarchy.
element
- the annotated elementannotationType
- the annotation type to findAnnotation
, or null
if not foundfindMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
,
getMergedAnnotationAttributes(AnnotatedElement, Class)
@Deprecated public static <A extends java.lang.annotation.Annotation> A findMergedAnnotation(java.lang.reflect.AnnotatedElement element, java.lang.String annotationName)
findMergedAnnotation(AnnotatedElement, Class)
instead.annotationName
within
the annotation hierarchy above the supplied element
,
merge that annotation's attributes with matching attributes from
annotations in lower levels of the annotation hierarchy, and synthesize
the result back into an annotation of the specified annotationName
.
@AliasFor
semantics are fully supported, both
within a single annotation and within the annotation hierarchy.
This method delegates to findMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
(supplying false
for classValuesAsString
and nestedAnnotationsAsMap
)
and AnnotationUtils.synthesizeAnnotation(Map, Class, AnnotatedElement)
.
element
- the annotated elementannotationName
- the fully qualified class name of the annotation type to findAnnotation
, or null
if not foundfindMergedAnnotation(AnnotatedElement, Class)
,
findMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
,
AnnotationUtils.synthesizeAnnotation(Map, Class, AnnotatedElement)
public static AnnotationAttributes findMergedAnnotationAttributes(java.lang.reflect.AnnotatedElement element, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, boolean classValuesAsString, boolean nestedAnnotationsAsMap)
annotationName
within
the annotation hierarchy above the supplied element
and
merge that annotation's attributes with matching attributes from
annotations in lower levels of the annotation hierarchy.
Attributes from lower levels in the annotation hierarchy override
attributes of the same name from higher levels, and
@AliasFor
semantics are fully supported, both
within a single annotation and within the annotation hierarchy.
In contrast to getAllAnnotationAttributes(java.lang.reflect.AnnotatedElement, java.lang.String)
, the search
algorithm used by this method will stop searching the annotation
hierarchy once the first annotation of the specified
annotationName
has been found. As a consequence, additional
annotations of the specified annotationName
will be ignored.
This method follows find semantics as described in the class-level javadoc.
element
- the annotated elementannotationType
- the annotation type to findclassValuesAsString
- whether to convert Class references into
Strings or to preserve them as Class referencesnestedAnnotationsAsMap
- whether to convert nested Annotation
instances into AnnotationAttributes
maps or to preserve them
as Annotation instancesAnnotationAttributes
, or null
if
not foundfindMergedAnnotation(AnnotatedElement, Class)
,
getMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
public static AnnotationAttributes findMergedAnnotationAttributes(java.lang.reflect.AnnotatedElement element, java.lang.String annotationName, boolean classValuesAsString, boolean nestedAnnotationsAsMap)
annotationName
within
the annotation hierarchy above the supplied element
and
merge that annotation's attributes with matching attributes from
annotations in lower levels of the annotation hierarchy.
Attributes from lower levels in the annotation hierarchy override
attributes of the same name from higher levels, and
@AliasFor
semantics are fully supported, both
within a single annotation and within the annotation hierarchy.
In contrast to getAllAnnotationAttributes(java.lang.reflect.AnnotatedElement, java.lang.String)
, the search
algorithm used by this method will stop searching the annotation
hierarchy once the first annotation of the specified
annotationName
has been found. As a consequence, additional
annotations of the specified annotationName
will be ignored.
This method follows find semantics as described in the class-level javadoc.
element
- the annotated elementannotationName
- the fully qualified class name of the annotation type to findclassValuesAsString
- whether to convert Class references into Strings or to
preserve them as Class referencesnestedAnnotationsAsMap
- whether to convert nested Annotation instances into
AnnotationAttributes
maps or to preserve them as Annotation instancesAnnotationAttributes
, or null
if not foundfindMergedAnnotation(AnnotatedElement, Class)
,
getMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
@Deprecated public static AnnotationAttributes getAnnotationAttributes(java.lang.reflect.AnnotatedElement element, java.lang.String annotationName)
getMergedAnnotationAttributes(AnnotatedElement, String)
instead.@Deprecated public static AnnotationAttributes getAnnotationAttributes(java.lang.reflect.AnnotatedElement element, java.lang.String annotationName, boolean classValuesAsString, boolean nestedAnnotationsAsMap)
getMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
instead.public static MultiValueMap<java.lang.String,java.lang.Object> getAllAnnotationAttributes(java.lang.reflect.AnnotatedElement element, java.lang.String annotationName)
annotationName
in the annotation hierarchy above the supplied
AnnotatedElement
and store the results in a MultiValueMap
.
Note: in contrast to getMergedAnnotationAttributes(AnnotatedElement, String)
,
this method does not support attribute overrides.
This method follows get semantics as described in the class-level javadoc.
element
- the annotated elementannotationName
- the fully qualified class name of the annotation type to findMultiValueMap
keyed by attribute name, containing the annotation
attributes from all annotations found, or null
if not foundgetAllAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
public static MultiValueMap<java.lang.String,java.lang.Object> getAllAnnotationAttributes(java.lang.reflect.AnnotatedElement element, java.lang.String annotationName, boolean classValuesAsString, boolean nestedAnnotationsAsMap)
annotationName
in the annotation hierarchy above
the supplied AnnotatedElement
and store the results in a
MultiValueMap
.
Note: in contrast to getMergedAnnotationAttributes(AnnotatedElement, String)
,
this method does not support attribute overrides.
This method follows get semantics as described in the class-level javadoc.
element
- the annotated elementannotationName
- the fully qualified class name of the annotation type to findclassValuesAsString
- whether to convert Class references into Strings or to
preserve them as Class referencesnestedAnnotationsAsMap
- whether to convert nested Annotation instances into
AnnotationAttributes
maps or to preserve them as Annotation instancesMultiValueMap
keyed by attribute name, containing the annotation
attributes from all annotations found, or null
if not foundprivate static <T> T searchWithGetSemantics(java.lang.reflect.AnnotatedElement element, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.lang.String annotationName, AnnotatedElementUtils.Processor<T> processor)
annotationName
on
the specified element
, following get semantics.element
- the annotated elementannotationType
- the annotation type on which to find meta-annotationsannotationName
- the fully qualified class name of the annotation
type to find (as an alternative to annotationType
)processor
- the processor to delegate tonull
private static <T> T searchWithGetSemantics(java.lang.reflect.AnnotatedElement element, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.lang.String annotationName, AnnotatedElementUtils.Processor<T> processor, java.util.Set<java.lang.reflect.AnnotatedElement> visited, int metaDepth)
searchWithGetSemantics(java.lang.reflect.AnnotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation>, java.lang.String, org.springframework.core.annotation.AnnotatedElementUtils.Processor<T>)
method, avoiding endless recursion by tracking which annotated elements
have already been visited.
The metaDepth
parameter is explained in the
process()
method of the AnnotatedElementUtils.Processor
API.
element
- the annotated elementannotationType
- the annotation type on which to find meta-annotationsannotationName
- the fully qualified class name of the annotation
type to find (as an alternative to annotationType
)processor
- the processor to delegate tovisited
- the set of annotated elements that have already been visitedmetaDepth
- the meta-depth of the annotationnull
private static <T> T searchWithGetSemanticsInAnnotations(java.lang.reflect.AnnotatedElement annotatedElement, java.util.List<java.lang.annotation.Annotation> annotations, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.lang.String annotationName, AnnotatedElementUtils.Processor<T> processor, java.util.Set<java.lang.reflect.AnnotatedElement> visited, int metaDepth)
searchWithGetSemantics(AnnotatedElement, Class, String, Processor, Set, int)
to perform the actual search within the supplied list of annotations.
This method should be invoked first with locally declared annotations and then subsequently with inherited annotations, thereby allowing local annotations to take precedence over inherited annotations.
The metaDepth
parameter is explained in the
process()
method of the AnnotatedElementUtils.Processor
API.
annotatedElement
- the element that is annotated with the supplied
annotations, used for contextual logging; may be null
if unknownannotations
- the annotations to search inannotationType
- the annotation type on which to find meta-annotationsannotationName
- the fully qualified class name of the annotation
type to find (as an alternative to annotationType
)processor
- the processor to delegate tovisited
- the set of annotated elements that have already been visitedmetaDepth
- the meta-depth of the annotationnull
private static <T> T searchWithFindSemantics(java.lang.reflect.AnnotatedElement element, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.lang.String annotationName, AnnotatedElementUtils.Processor<T> processor)
annotationName
on
the specified element
, following find semantics.element
- the annotated elementannotationType
- the annotation type on which to find meta-annotationsannotationName
- the fully qualified class name of the annotation
type to find (as an alternative to annotationType
)processor
- the processor to delegate tonull
private static <T> T searchWithFindSemantics(java.lang.reflect.AnnotatedElement element, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.lang.String annotationName, AnnotatedElementUtils.Processor<T> processor, java.util.Set<java.lang.reflect.AnnotatedElement> visited, int metaDepth)
searchWithFindSemantics(java.lang.reflect.AnnotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation>, java.lang.String, org.springframework.core.annotation.AnnotatedElementUtils.Processor<T>)
method, avoiding endless recursion by tracking which annotated elements
have already been visited.
The metaDepth
parameter is explained in the
process()
method of the AnnotatedElementUtils.Processor
API.
element
- the annotated elementannotationType
- the annotation type on which to find meta-annotationsannotationName
- the fully qualified class name of the annotation
type to find (as an alternative to annotationType
)processor
- the processor to delegate tovisited
- the set of annotated elements that have already been visitedmetaDepth
- the meta-depth of the annotationnull
private static <T> T searchOnInterfaces(java.lang.reflect.Method method, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.lang.String annotationName, AnnotatedElementUtils.Processor<T> processor, java.util.Set<java.lang.reflect.AnnotatedElement> visited, int metaDepth, java.lang.Class<?>[] ifcs)