public abstract class AnnotationUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T extends Annotation> |
findAnnotation(AnnotatedElement element,
Class<T> annotationType)
Find an annotation of given
annotationType on the given element , considering that the
given annotationType may be present as a meta annotation on any other annotation on that element. |
static Annotation |
findAnnotation(AnnotatedElement element,
String annotationType)
Find an annotation of given
annotationType as String on the given element ,
considering that the given annotationType may be present as a meta annotation on any other
annotation on that element. |
static Optional<Map<String,Object>> |
findAnnotationAttributes(AnnotatedElement element,
Class<? extends Annotation> annotationType)
Find the attributes of an annotation of type
annotationType on the given element . |
static Optional<Map<String,Object>> |
findAnnotationAttributes(AnnotatedElement element,
String annotationName)
Find the attributes of an annotation with given
annotationName on the given element . |
public static <T extends Annotation> T findAnnotation(AnnotatedElement element, Class<T> annotationType)
annotationType
on the given element
, considering that the
given annotationType
may be present as a meta annotation on any other annotation on that element.T
- The generic type of the annotationelement
- The element to inspectannotationType
- The type of annotation to findnull
if no such annotation is present.public static Annotation findAnnotation(AnnotatedElement element, String annotationType)
annotationType
as String on the given element
,
considering that the given annotationType
may be present as a meta annotation on any other
annotation on that element.element
- The element to inspectannotationType
- The type of annotation as String to findnull
if no such annotation is present.public static Optional<Map<String,Object>> findAnnotationAttributes(AnnotatedElement element, String annotationName)
annotationName
on the given element
. The returned
optional has a value present if the annotation has been found, either directly on the element
, or as a
meta-annotation.
The map of attributes contains all the attributes found on the annotation, as well as attributes of any annotations on which the targeted annotation was placed (directly, or indirectly).
element
- The element for find the annotation onannotationName
- The name of the annotation to findpublic static Optional<Map<String,Object>> findAnnotationAttributes(AnnotatedElement element, Class<? extends Annotation> annotationType)
annotationType
on the given element
. The returned
optional has a value present if the annotation has been found, either directly on the element
, or as a
meta-annotation.
The map of attributes contains all the attributes found on the annotation, as well as attributes of any
annotations on which the targeted annotation was placed (directly, or indirectly). Note that the value
property of annotations is reported as the simple class name (lowercase first character) of the annotation. This
allows specific attribute overrides for annotations that have multiple meta-annotation with the value
property.
element
- The element for find the annotation onannotationType
- The type of the annotation to findCopyright © 2010–2017. All rights reserved.