public abstract class AnnotationUtils extends Object
Modifier and Type | Method and Description |
---|---|
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 . |
static boolean |
isAnnotationPresent(AnnotatedElement element,
Class<? extends Annotation> annotationType)
Indicates whether an annotation of given
annotationType is present on the given element ,
considering that the given annotationType may be present as a meta annotation on any other annotation
on that element. |
static boolean |
isAnnotationPresent(AnnotatedElement element,
String annotationType)
Indicates whether an annotation with given
annotationType is present on the given element ,
considering that the given annotationType may be present as a meta annotation on any other annotation
on that element. |
public static boolean isAnnotationPresent(AnnotatedElement element, Class<? extends Annotation> annotationType)
annotationType
is present 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 to findtrue
if such annotation is present.public static boolean isAnnotationPresent(AnnotatedElement element, String annotationType)
annotationType
is present 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 name of the annotation to findtrue
if 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–2018. All rights reserved.