public class AnnotatedElementUtils extends 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(),
getAllMergedAnnotations(), getMergedRepeatableAnnotations(),
findMergedAnnotationAttributes(), findMergedAnnotation(),
findAllMergedAnnotations(), and findMergedRepeatableAnnotations()
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:
@InheritedMethods 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| Constructor and Description |
|---|
AnnotatedElementUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <A extends Annotation> |
findAllMergedAnnotations(AnnotatedElement element,
Class<A> annotationType)
Find all annotations of the specified
annotationType
within the annotation hierarchy above the supplied element;
and for each annotation found, merge that annotation's attributes with
matching attributes from annotations in lower levels of the annotation
hierarchy and synthesize the results back into an annotation of the specified
annotationType. |
static <A extends Annotation> |
findMergedAnnotation(AnnotatedElement element,
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 Annotation> |
findMergedAnnotation(AnnotatedElement element,
String annotationName)
Deprecated.
As of Spring Framework 4.2.3, use
findMergedAnnotation(AnnotatedElement, Class) instead. |
static AnnotationAttributes |
findMergedAnnotationAttributes(AnnotatedElement element,
Class<? extends Annotation> annotationType,
boolean classValuesAsString,
boolean nestedAnnotationsAsMap)
Find 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 |
findMergedAnnotationAttributes(AnnotatedElement element,
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 <A extends Annotation> |
findMergedRepeatableAnnotations(AnnotatedElement element,
Class<A> annotationType)
Find all repeatable annotations of the specified
annotationType
within the annotation hierarchy above the supplied element;
and for each annotation found, merge that annotation's attributes with
matching attributes from annotations in lower levels of the annotation
hierarchy and synthesize the results back into an annotation of the specified
annotationType. |
static <A extends Annotation> |
findMergedRepeatableAnnotations(AnnotatedElement element,
Class<A> annotationType,
Class<? extends Annotation> containerType)
Find all repeatable annotations of the specified
annotationType
within the annotation hierarchy above the supplied element;
and for each annotation found, merge that annotation's attributes with
matching attributes from annotations in lower levels of the annotation
hierarchy and synthesize the results back into an annotation of the specified
annotationType. |
static AnnotatedElement |
forAnnotations(Annotation... annotations)
Build an adapted
AnnotatedElement for the given annotations,
typically for use with other methods on AnnotatedElementUtils. |
static MultiValueMap<String,Object> |
getAllAnnotationAttributes(AnnotatedElement element,
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<String,Object> |
getAllAnnotationAttributes(AnnotatedElement element,
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 <A extends Annotation> |
getAllMergedAnnotations(AnnotatedElement element,
Class<A> annotationType)
Get all annotations of the specified
annotationType
within the annotation hierarchy above the supplied element;
and for each annotation found, merge that annotation's attributes with
matching attributes from annotations in lower levels of the annotation
hierarchy and synthesize the results back into an annotation of the specified
annotationType. |
static AnnotationAttributes |
getAnnotationAttributes(AnnotatedElement element,
String annotationName)
Deprecated.
As of Spring Framework 4.2, use
getMergedAnnotationAttributes(AnnotatedElement, String) instead. |
static AnnotationAttributes |
getAnnotationAttributes(AnnotatedElement element,
String annotationName,
boolean classValuesAsString,
boolean nestedAnnotationsAsMap)
Deprecated.
As of Spring Framework 4.2, use
getMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean) instead. |
static <A extends Annotation> |
getMergedAnnotation(AnnotatedElement element,
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(AnnotatedElement element,
Class<? extends 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(AnnotatedElement element,
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(AnnotatedElement element,
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 <A extends Annotation> |
getMergedRepeatableAnnotations(AnnotatedElement element,
Class<A> annotationType)
Get all repeatable annotations of the specified
annotationType
within the annotation hierarchy above the supplied element;
and for each annotation found, merge that annotation's attributes with
matching attributes from annotations in lower levels of the annotation
hierarchy and synthesize the results back into an annotation of the specified
annotationType. |
static <A extends Annotation> |
getMergedRepeatableAnnotations(AnnotatedElement element,
Class<A> annotationType,
Class<? extends Annotation> containerType)
Get all repeatable annotations of the specified
annotationType
within the annotation hierarchy above the supplied element;
and for each annotation found, merge that annotation's attributes with
matching attributes from annotations in lower levels of the annotation
hierarchy and synthesize the results back into an annotation of the specified
annotationType. |
static Set<String> |
getMetaAnnotationTypes(AnnotatedElement element,
Class<? extends 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 Set<String> |
getMetaAnnotationTypes(AnnotatedElement element,
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 |
hasAnnotation(AnnotatedElement element,
Class<? extends Annotation> annotationType)
Determine if an annotation of the specified
annotationType
is available on the supplied AnnotatedElement or
within the annotation hierarchy above the specified element. |
static boolean |
hasMetaAnnotationTypes(AnnotatedElement element,
Class<? extends Annotation> annotationType)
Determine if the supplied
AnnotatedElement is annotated with
a composed annotation that is meta-annotated with an
annotation of the specified annotationType. |
static boolean |
hasMetaAnnotationTypes(AnnotatedElement element,
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(AnnotatedElement element,
Class<? extends Annotation> annotationType)
Determine if an annotation of the specified
annotationType
is present on the supplied AnnotatedElement or
within the annotation hierarchy above the specified element. |
static boolean |
isAnnotated(AnnotatedElement element,
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. |
public static AnnotatedElement forAnnotations(Annotation... annotations)
AnnotatedElement for the given annotations,
typically for use with other methods on AnnotatedElementUtils.annotations - the annotations to expose through the AnnotatedElementpublic static Set<String> getMetaAnnotationTypes(AnnotatedElement element, Class<? extends 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 Set<String> getMetaAnnotationTypes(AnnotatedElement element, 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(AnnotatedElement element, Class<? extends Annotation> annotationType)
AnnotatedElement is annotated with
a composed annotation that is meta-annotated with an
annotation of the specified annotationType.
This method follows get semantics as described in the class-level javadoc.
element - the annotated elementannotationType - 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 hasMetaAnnotationTypes(AnnotatedElement element, 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(AnnotatedElement element, Class<? extends Annotation> annotationType)
annotationType
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 to findtrue if a matching annotation is presenthasAnnotation(AnnotatedElement, Class)public static boolean isAnnotated(AnnotatedElement element, 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 present@Deprecated public static AnnotationAttributes getAnnotationAttributes(AnnotatedElement element, String annotationName)
getMergedAnnotationAttributes(AnnotatedElement, String) instead.@Deprecated public static AnnotationAttributes getAnnotationAttributes(AnnotatedElement element, String annotationName, boolean classValuesAsString, boolean nestedAnnotationsAsMap)
getMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean) instead.public static AnnotationAttributes getMergedAnnotationAttributes(AnnotatedElement element, Class<? extends 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(AnnotatedElement element, 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(AnnotatedElement element, 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 Annotation> A getMergedAnnotation(AnnotatedElement element, 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 <A extends Annotation> Set<A> getAllMergedAnnotations(AnnotatedElement element, Class<A> annotationType)
annotationType
within the annotation hierarchy above the supplied element;
and for each annotation found, merge that annotation's attributes with
matching attributes from annotations in lower levels of the annotation
hierarchy and synthesize the results back into an annotation of the specified
annotationType.
@AliasFor semantics are fully supported, both within a
single annotation and within annotation hierarchies.
This method follows get semantics as described in the class-level javadoc.
element - the annotated element (never null)annotationType - the annotation type to find (never null)Annotations found,
or an empty set if none were foundgetMergedAnnotation(AnnotatedElement, Class),
getAllAnnotationAttributes(AnnotatedElement, String),
findAllMergedAnnotations(AnnotatedElement, Class)public static <A extends Annotation> Set<A> getMergedRepeatableAnnotations(AnnotatedElement element, Class<A> annotationType)
annotationType
within the annotation hierarchy above the supplied element;
and for each annotation found, merge that annotation's attributes with
matching attributes from annotations in lower levels of the annotation
hierarchy and synthesize the results back into an annotation of the specified
annotationType.
The container type that holds the repeatable annotations will be looked up
via Repeatable.
@AliasFor semantics are fully supported, both within a
single annotation and within annotation hierarchies.
This method follows get semantics as described in the class-level javadoc.
element - the annotated element (never null)annotationType - the annotation type to find (never null)Annotations found,
or an empty set if none were foundIllegalArgumentException - if the element or annotationType
is null, or if the container type cannot be resolvedgetMergedAnnotation(AnnotatedElement, Class),
getAllMergedAnnotations(AnnotatedElement, Class),
getMergedRepeatableAnnotations(AnnotatedElement, Class, Class)public static <A extends Annotation> Set<A> getMergedRepeatableAnnotations(AnnotatedElement element, Class<A> annotationType, Class<? extends Annotation> containerType)
annotationType
within the annotation hierarchy above the supplied element;
and for each annotation found, merge that annotation's attributes with
matching attributes from annotations in lower levels of the annotation
hierarchy and synthesize the results back into an annotation of the specified
annotationType.
@AliasFor semantics are fully supported, both within a
single annotation and within annotation hierarchies.
This method follows get semantics as described in the class-level javadoc.
element - the annotated element (never null)annotationType - the annotation type to find (never null)containerType - the type of the container that holds the annotations;
may be null if the container type should be looked up via
RepeatableAnnotations found,
or an empty set if none were foundIllegalArgumentException - if the element or annotationType
is null, or if the container type cannot be resolvedAnnotationConfigurationException - if the supplied containerType
is not a valid container annotation for the supplied annotationTypegetMergedAnnotation(AnnotatedElement, Class),
getAllMergedAnnotations(AnnotatedElement, Class)public static MultiValueMap<String,Object> getAllAnnotationAttributes(AnnotatedElement element, 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<String,Object> getAllAnnotationAttributes(AnnotatedElement element, 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 foundpublic static boolean hasAnnotation(AnnotatedElement element, Class<? extends Annotation> annotationType)
annotationType
is available on the supplied AnnotatedElement or
within the annotation hierarchy above the specified element.
If this method returns true, then findMergedAnnotationAttributes(java.lang.reflect.AnnotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation>, boolean, boolean)
will return a non-null value.
This method follows find semantics as described in the class-level javadoc.
element - the annotated elementannotationType - the annotation type to findtrue if a matching annotation is presentisAnnotated(AnnotatedElement, Class)public static AnnotationAttributes findMergedAnnotationAttributes(AnnotatedElement element, Class<? extends Annotation> annotationType, boolean classValuesAsString, boolean nestedAnnotationsAsMap)
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.
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
annotationType has been found. As a consequence, additional
annotations of the specified annotationType 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(AnnotatedElement element, 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)public static <A extends Annotation> A findMergedAnnotation(AnnotatedElement element, 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 follows find semantics as described in the class-level javadoc.
element - the annotated elementannotationType - the annotation type to findAnnotation, or null if not foundfindAllMergedAnnotations(AnnotatedElement, Class),
findMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean),
getMergedAnnotationAttributes(AnnotatedElement, Class)@Deprecated public static <A extends Annotation> A findMergedAnnotation(AnnotatedElement element, 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).
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 findAnnotation, or null if not foundfindMergedAnnotation(AnnotatedElement, Class),
findMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean),
AnnotationUtils.synthesizeAnnotation(Map, Class, AnnotatedElement)public static <A extends Annotation> Set<A> findAllMergedAnnotations(AnnotatedElement element, Class<A> annotationType)
annotationType
within the annotation hierarchy above the supplied element;
and for each annotation found, merge that annotation's attributes with
matching attributes from annotations in lower levels of the annotation
hierarchy and synthesize the results back into an annotation of the specified
annotationType.
@AliasFor semantics are fully supported, both within a
single annotation and within annotation hierarchies.
This method follows find semantics as described in the class-level javadoc.
element - the annotated element (never null)annotationType - the annotation type to find (never null)Annotations found,
or an empty set if none were foundfindMergedAnnotation(AnnotatedElement, Class),
getAllMergedAnnotations(AnnotatedElement, Class)public static <A extends Annotation> Set<A> findMergedRepeatableAnnotations(AnnotatedElement element, Class<A> annotationType)
annotationType
within the annotation hierarchy above the supplied element;
and for each annotation found, merge that annotation's attributes with
matching attributes from annotations in lower levels of the annotation
hierarchy and synthesize the results back into an annotation of the specified
annotationType.
The container type that holds the repeatable annotations will be looked up
via Repeatable.
@AliasFor semantics are fully supported, both within a
single annotation and within annotation hierarchies.
This method follows find semantics as described in the class-level javadoc.
element - the annotated element (never null)annotationType - the annotation type to find (never null)Annotations found,
or an empty set if none were foundIllegalArgumentException - if the element or annotationType
is null, or if the container type cannot be resolvedfindMergedAnnotation(AnnotatedElement, Class),
findAllMergedAnnotations(AnnotatedElement, Class),
findMergedRepeatableAnnotations(AnnotatedElement, Class, Class)public static <A extends Annotation> Set<A> findMergedRepeatableAnnotations(AnnotatedElement element, Class<A> annotationType, Class<? extends Annotation> containerType)
annotationType
within the annotation hierarchy above the supplied element;
and for each annotation found, merge that annotation's attributes with
matching attributes from annotations in lower levels of the annotation
hierarchy and synthesize the results back into an annotation of the specified
annotationType.
@AliasFor semantics are fully supported, both within a
single annotation and within annotation hierarchies.
This method follows find semantics as described in the class-level javadoc.
element - the annotated element (never null)annotationType - the annotation type to find (never null)containerType - the type of the container that holds the annotations;
may be null if the container type should be looked up via
RepeatableAnnotations found,
or an empty set if none were foundIllegalArgumentException - if the element or annotationType
is null, or if the container type cannot be resolvedAnnotationConfigurationException - if the supplied containerType
is not a valid container annotation for the supplied annotationTypefindMergedAnnotation(AnnotatedElement, Class),
findAllMergedAnnotations(AnnotatedElement, Class)