List of utility methods to do Reflection Annotation
Annotation | getAnnotation(Class> annotationClass, Annotation[] annotations) Searches for annotation instance of the type specified by annotationClass in the array of annotations.
for (Annotation a : annotations) { if (annotationClass.isInstance(a)) { return a; return null; |
T | getAnnotation(Class> base, Class get Annotation T annotation = null; annotation = base.getAnnotation(annotationClass); if (null != annotation) { return annotation; Class<?>[] implementees = base.getInterfaces(); for (int i = 0; null == annotation && i < implementees.length; i++) { annotation = implementees[i].getAnnotation(annotationClass); ... |
Annotation | getAnnotation(Class> c, Class extends Annotation> annotationClass) Returns true if specified class is annotated with annotation of annotationClass type.
return c.getAnnotation(annotationClass);
|
A | getAnnotation(Class> classForAnnotation, Class annotationClass) Returns annotation for specified class. if (classForAnnotation == null) { return null; A result = classForAnnotation.getAnnotation(annotationClass); if (result != null) { return result; return getAnnotation(classForAnnotation.getSuperclass(), annotationClass); ... |
A | getAnnotation(Class> clazz, Class annotationClass) get Annotation return clazz.getAnnotation(annotationClass);
|
A | getAnnotation(Class> clazz, Class annotationClass) This is proxy ready implementation Class#getAnnotation(Class) . final A annotation = clazz.getAnnotation(annotationClass); if (annotation == null && clazz.isSynthetic()) { return getAnnotation(clazz.getSuperclass(), annotationClass); } else { return annotation; |
A | getAnnotation(Class> clazz, Class annotClass, boolean forceInherit) get Annotation boolean inherited = forceInherit || annotClass.isAnnotationPresent(Inherited.class); LinkedList<Class<?>> workQueue = new LinkedList<Class<?>>(); workQueue.add(clazz); while (!workQueue.isEmpty()) { clazz = workQueue.removeFirst(); A result = clazz.getAnnotation(annotClass); if (result != null || !inherited) { return result; ... |
R | getAnnotation(Class> clazz, Class get Annotation return (R) findAnnotation(clazz, annotationClass, new HashSet<>()); |
T | getAnnotation(Class> clazz, Class Inspects the class passed in for the class level annotation specified. while (true) { T a = clazz.getAnnotation(ann); if (a != null) return a; if (!clazz.isInterface()) { Class<?>[] interfaces = clazz.getInterfaces(); for (Class<?> inter : interfaces) { a = getAnnotation(inter, ann); ... |
T | getAnnotation(Class> clazz, Class get Annotation while (clazz != null) { T ann = clazz.getAnnotation(annClazz); if (ann != null) { return ann; clazz = clazz.getSuperclass(); return null; ... |