List of utility methods to do Reflection Annotation
T | getAnnotation(Annotation[] annotaions, Class extends Annotation> T) find an annotation from an array for (int i = 0; i < annotaions.length; i++) { if (annotaions[i].annotationType().equals(T)) { return (T) annotaions[i]; return null; |
A | getAnnotation(Annotation[] annotations, Class annotationType) Gets the annotation that has the specified type, or null if there isn't one for (Annotation anno : annotations) if (annotationType.isAssignableFrom(anno.getClass())) return (A) anno; return null; |
Optional | getAnnotation(Annotation[] annotations, Class get Annotation for (Annotation a : annotations) { if (annotationClazz.isAssignableFrom(a.getClass())) { return Optional.of((T) a); return Optional.empty(); |
T | getAnnotation(Annotation[] annotations, Class Finds an annotation of given annotationType from the given annotations . for (Annotation annotation : annotations) { if (annotation.annotationType().equals(annotationType)) { return (T) annotation; return null; |
T | getAnnotation(Annotation[] annotations, Class get Annotation for (Annotation annotation : annotations) if (clazz.isAssignableFrom(annotation.getClass())) return clazz.cast(annotation); return null; |
T | getAnnotation(Class clazz, Class get Annotation if (clazz.isAnnotationPresent(annotation)) { Annotation value = clazz.getAnnotation(annotation); return annotation.cast(value); return null; |
Annotation | getAnnotation(Class cls, Class annotationCls) get Annotation if (cls == null) { return null; Annotation ret = cls.getAnnotation(annotationCls); if (ret != null) { return ret; ret = getAnnotation(cls.getSuperclass(), annotationCls); ... |
Annotation | getAnnotation(Class cls, Class extends Annotation> annotationCls) get Annotation Annotation res = cls.getAnnotation(annotationCls); if (res != null) { return res; } else if (!cls.equals(Object.class)) { return getAnnotation(cls.getSuperclass(), annotationCls); } else { return null; |
Annotation | getAnnotation(Class theExaminedClass, Class theExpectedAnnotation) The method returns the expected annotation. return getAnnotation(theExaminedClass, theExpectedAnnotation, false);
|
Annotation | getAnnotation(Class extends Annotation> anno, Class> cl) get Annotation return cl.getAnnotation(anno);
|