Class AnnotationUtils
- java.lang.Object
-
- ch.systemsx.cisd.common.reflection.AnnotationUtils
-
public final class AnnotationUtils extends java.lang.Object
General utility methods for working with annotations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AnnotationUtils.Parameter<A extends java.lang.annotation.Annotation>
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<java.lang.reflect.Field>
getAnnotatedFieldList(java.lang.Class<?> clazz, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
For givenClass
returns a list of fields that are annotated with given annotationClass.static java.util.List<java.lang.reflect.Method>
getAnnotatedMethodList(java.lang.Class<?> clazz, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
For givenClass
returns a list of methods that are annotated with given annotationClass.static <A extends java.lang.annotation.Annotation>
java.util.List<AnnotationUtils.Parameter<A>>getAnnotatedParameters(java.lang.reflect.Method method, java.lang.Class<A> annotationType)
Returns a list of method parameters where given annotation could be found.static <A extends java.lang.annotation.Annotation>
AtryGetAnnotation(java.lang.annotation.Annotation[] annotations, java.lang.Class<A> annotationType)
From the list of given annotations tries to return the one of given type.
-
-
-
Method Detail
-
getAnnotatedMethodList
public static final java.util.List<java.lang.reflect.Method> getAnnotatedMethodList(java.lang.Class<?> clazz, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
For givenClass
returns a list of methods that are annotated with given annotationClass.
-
getAnnotatedFieldList
public static final java.util.List<java.lang.reflect.Field> getAnnotatedFieldList(java.lang.Class<?> clazz, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
For givenClass
returns a list of fields that are annotated with given annotationClass.
-
tryGetAnnotation
public static final <A extends java.lang.annotation.Annotation> A tryGetAnnotation(java.lang.annotation.Annotation[] annotations, java.lang.Class<A> annotationType)
From the list of given annotations tries to return the one of given type.- Returns:
null
if not found.
-
getAnnotatedParameters
public static final <A extends java.lang.annotation.Annotation> java.util.List<AnnotationUtils.Parameter<A>> getAnnotatedParameters(java.lang.reflect.Method method, java.lang.Class<A> annotationType)
Returns a list of method parameters where given annotation could be found.- Returns:
- never
null
but could return an empty list.
-
-