Package org.int4.dirk.util
Class Annotations
- java.lang.Object
-
- org.int4.dirk.util.Annotations
-
public class Annotations extends java.lang.ObjectUtilities for working with annotations.
-
-
Constructor Summary
Constructors Constructor Description Annotations()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Set<java.lang.annotation.Annotation>findAnnotations(java.lang.reflect.AnnotatedElement element, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)Finds all annotations of the given type recursively from the givenAnnotatedElement.static java.util.Set<java.lang.annotation.Annotation>findDirectlyMetaAnnotatedAnnotations(java.lang.reflect.AnnotatedElement element, java.lang.annotation.Annotation metaAnnotation)Recursively finds annotations directly annotated by a given meta annotation, starting from the givenAnnotatedElement.static java.util.Set<java.lang.annotation.Annotation>findDirectlyMetaAnnotatedAnnotations(java.lang.reflect.AnnotatedElement element, java.lang.Class<? extends java.lang.annotation.Annotation> metaAnnotation)Recursively finds annotations directly annotated by a given meta annotation class, starting from the givenAnnotatedElement.static java.util.List<java.lang.annotation.Annotation>findMetaAnnotatedAnnotations(java.lang.reflect.AnnotatedElement element, java.lang.annotation.Annotation metaAnnotation)ReturnsAnnotations on the givenAnnotatedElementwhich are annotated with the given meta annotation directly or indirectly.static booleanisMetaAnnotated(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.lang.annotation.Annotation metaAnnotation)Returnstrueif the given annotationClassis directly or indirectly meta annotated with the given meta annotation.static <A extends java.lang.annotation.Annotation>
Aof(java.lang.Class<A> annotationClass)Creates anAnnotationwithout parameters.static <A extends java.lang.annotation.Annotation>
Aof(java.lang.Class<A> annotationClass, java.util.Map<java.lang.String,java.lang.Object> values)Creates anAnnotationwith parameters.
-
-
-
Method Detail
-
of
public static <A extends java.lang.annotation.Annotation> A of(java.lang.Class<A> annotationClass, java.util.Map<java.lang.String,java.lang.Object> values)Creates anAnnotationwith parameters.- Type Parameters:
A- the annotation type- Parameters:
annotationClass- aClasswhich extendsAnnotation, cannot benullvalues- a map of values for the annotations parameters, cannot benull- Returns:
- an
Annotation, nevernull - Throws:
java.lang.IllegalArgumentException- when the given parameters could not be converted to an annotation
-
of
public static <A extends java.lang.annotation.Annotation> A of(java.lang.Class<A> annotationClass)
Creates anAnnotationwithout parameters.- Type Parameters:
A- the annotation type- Parameters:
annotationClass- aClasswhich extendsAnnotation, cannot benull- Returns:
- an
Annotation, nevernull - Throws:
java.lang.IllegalArgumentException- when the given parameters could not be converted to an annotation
-
findAnnotations
public static java.util.Set<java.lang.annotation.Annotation> findAnnotations(java.lang.reflect.AnnotatedElement element, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)Finds all annotations of the given type recursively from the givenAnnotatedElement.- Parameters:
element- anAnnotatedElement, cannot benullannotationType- aClasswhich extendsAnnotation, cannot benull- Returns:
- a set of
Annotations that were found directly or indirectly on the given element, nevernulland never containsnulls
-
findDirectlyMetaAnnotatedAnnotations
public static java.util.Set<java.lang.annotation.Annotation> findDirectlyMetaAnnotatedAnnotations(java.lang.reflect.AnnotatedElement element, java.lang.annotation.Annotation metaAnnotation)Recursively finds annotations directly annotated by a given meta annotation, starting from the givenAnnotatedElement. The annotations returned are not necessarily direct annotations on the given element, but can be meta annotations which are annotated with the given meta annotation.- Parameters:
element- anAnnotatedElement, cannot benullmetaAnnotation- anAnnotation, cannot benull- Returns:
- a mutable set of
Annotations directly annotated with the given meta annotation, nevernulland never containsnulls
-
findDirectlyMetaAnnotatedAnnotations
public static java.util.Set<java.lang.annotation.Annotation> findDirectlyMetaAnnotatedAnnotations(java.lang.reflect.AnnotatedElement element, java.lang.Class<? extends java.lang.annotation.Annotation> metaAnnotation)Recursively finds annotations directly annotated by a given meta annotation class, starting from the givenAnnotatedElement. The annotations returned are not necessarily direct annotations on the given element, but can be meta annotations which are annotated with the given meta annotation.- Parameters:
element- anAnnotatedElement, cannot benullmetaAnnotation- anAnnotation, cannot benull- Returns:
- a mutable set of
Annotations directly annotated with the given meta annotation, nevernulland never containsnulls
-
findMetaAnnotatedAnnotations
public static java.util.List<java.lang.annotation.Annotation> findMetaAnnotatedAnnotations(java.lang.reflect.AnnotatedElement element, java.lang.annotation.Annotation metaAnnotation)ReturnsAnnotations on the givenAnnotatedElementwhich are annotated with the given meta annotation directly or indirectly.- Parameters:
element- anAnnotatedElement, cannot benullmetaAnnotation- anAnnotation, cannot benull- Returns:
Annotations on the givenAnnotatedElementwhich are annotated with the given meta annotation directly or indirectly, nevernulland never containsnulls
-
isMetaAnnotated
public static boolean isMetaAnnotated(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.lang.annotation.Annotation metaAnnotation)Returnstrueif the given annotationClassis directly or indirectly meta annotated with the given meta annotation.- Parameters:
annotationType- aClasswhich extendsAnnotationto check, cannot benullmetaAnnotation- a metaAnnotationto search for, cannot benull- Returns:
trueif the givenAnnotationis directly or indirectly meta annotated with the given meta annotation, otherwisefalse
-
-