public class AnnotationReader extends Object
Modifier and Type | Method and Description |
---|---|
static <T extends Annotation> |
getAnnotationFor(Class<?> clazz,
Class<T> annotationType)
Helper to get an annotation for a class.
|
static <T extends Annotation> |
getAnnotationFor(Field field,
Class<T> annotationType)
Helper to get an annotation for a field.
|
static <T extends Annotation> |
getAnnotationsFor(Class<?> clazz,
Class<T> annotationType)
Helper to get annotations for a class by searching recursively the class
and all its super classes and implemented interfaces and their parent
interfaces.
|
static <A extends Annotation,T> |
getAnnotationValueFor(Class<?> clazz,
Class<A> annotationType,
Function<A,T> valueExtractor)
Gets a value from an annotation for a class.
|
static <A extends Annotation,T> |
getAnnotationValuesFor(Class<?> clazz,
Class<A> annotationType,
Function<A,T> valueExtractor)
Gets values from annotations for a class by searching recursively the
class and all its super classes and implemented interfaces and their
parent interfaces.
|
static List<HtmlImport> |
getHtmlImportAnnotations(Class<? extends Component> componentClass)
Finds all
HtmlImport annotations on the given Component
class, its super classes and implemented interfaces. |
static List<JavaScript> |
getJavaScriptAnnotations(Class<? extends Component> componentClass)
Finds all
JavaScript annotations on the given Component
class, its super classes and implemented interfaces. |
static List<StyleSheet> |
getStyleSheetAnnotations(Class<? extends Component> componentClass)
Finds all
StyleSheet annotations on the given Component
class, its super classes and implemented interfaces. |
public static List<StyleSheet> getStyleSheetAnnotations(Class<? extends Component> componentClass)
StyleSheet
annotations on the given Component
class, its super classes and implemented interfaces.componentClass
- the component class to search for the annotationfor what order the annotations are
in the list
public static List<JavaScript> getJavaScriptAnnotations(Class<? extends Component> componentClass)
JavaScript
annotations on the given Component
class, its super classes and implemented interfaces.componentClass
- the component class to search for the annotationfor what order the annotations are
in the list
public static List<HtmlImport> getHtmlImportAnnotations(Class<? extends Component> componentClass)
HtmlImport
annotations on the given Component
class, its super classes and implemented interfaces.componentClass
- the component class to search for the annotationfor what order the annotations are
in the list
public static <T extends Annotation> Optional<T> getAnnotationFor(Field field, Class<T> annotationType)
T
- the annotation typefield
- the field to checkannotationType
- the annotation type to look forOptional
annotation of the given type, or an
empty Optional if the field does not have the given annotationpublic static <T extends Annotation> Optional<T> getAnnotationFor(Class<?> clazz, Class<T> annotationType)
T
- the annotation typeclazz
- the class from which the annotation should be foundannotationType
- the annotation type to look forOptional
annotation of the given typepublic static <A extends Annotation,T> Optional<T> getAnnotationValueFor(Class<?> clazz, Class<A> annotationType, Function<A,T> valueExtractor)
A
- the annotation typeT
- the annotation value typeclazz
- the class from which the annotation should be foundannotationType
- the annotation type to look forvalueExtractor
- the function for extracting the value from the annotation if
an annotation is presentOptional
annotation valuepublic static <T extends Annotation> List<T> getAnnotationsFor(Class<?> clazz, Class<T> annotationType)
The annotations in the list are ordered top-down according to the class hierarchy. For each hierarchy level, the annotations from interfaces implemented at that level are on the list before the annotations of the class itself.
NOTE: the list may contain annotations with the same values.
T
- the annotation typeclazz
- the class from which the annotation should be foundannotationType
- the annotation type to look forpublic static <A extends Annotation,T> Stream<T> getAnnotationValuesFor(Class<?> clazz, Class<A> annotationType, Function<A,T> valueExtractor)
The values in the stream are ordered top-down according to the class hierarchy. For each hierarchy level, the values from annotations of interfaces implemented at that level are on the list before the values from annotations of the class itself.
NOTE: the stream may contain duplicates
A
- the annotation typeT
- the annotation value typeclazz
- the class from which the annotation should be foundannotationType
- the annotation type to look forvalueExtractor
- the function for extracting the value from any found
annotationCopyright © 2018. All rights reserved.