public class AnnotationUtil extends Object
Provides utility methods to deal with annotations.
| Constructor and Description |
|---|
AnnotationUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T extends Annotation> |
createAnnotation(Class<T> clazz)
Create an annotation instance from annotation class.
|
static <T extends Annotation> |
declaredAnnotation(AnnotatedElement annotatedElement,
Class<T> annoClass)
Return declared annotation with type
annoClass from an AnnotatedElement. |
static int |
hashCode(Annotation a)
Generate a hash code for the given annotation using the algorithm presented in the
Annotation.hashCode() API docs. |
static <T extends Annotation> |
tagAnnotation(Annotation annotation,
Class<T> tagClass)
Returns the
Annotation tagged on another annotation instance. |
public static <T extends Annotation> T declaredAnnotation(AnnotatedElement annotatedElement, Class<T> annoClass)
Return declared annotation with type annoClass from an AnnotatedElement.
T - the generic type of the annotation classannotatedElement - the annotated element (could be class, method or field)annoClass - the annotation classnull if not foundpublic static <T extends Annotation> T tagAnnotation(Annotation annotation, Class<T> tagClass)
Returns the Annotation tagged on another annotation instance.
T - the generic type of the expected annotationannotation - the annotation instancetagClass - the expected annotation classtagClasspublic static <T extends Annotation> T createAnnotation(Class<T> clazz)
Create an annotation instance from annotation class.
T - the generic type of the annoationclazz - the annotation classpublic static int hashCode(Annotation a)
Generate a hash code for the given annotation using the algorithm presented in the Annotation.hashCode() API docs.
a - the Annotation for a hash code calculation is desired, not nullRuntimeException - if an Exception is encountered during annotation member accessIllegalStateException - if an annotation method invocation returns nullCopyright © 2016–2018 OSGL (Open Source General Library). All rights reserved.