List of utility methods to do Reflection Annotation
T | getAnnotation(Class> clazz, Class get Annotation if (clazz.isAnnotationPresent(annotation)) return clazz.getAnnotation(annotation); Class<?>[] intfaces = clazz.getInterfaces(); for (Class<?> intface : intfaces) { try { if (intface.isAnnotationPresent(annotation)) return intface.getAnnotation(annotation); } catch (SecurityException e) { ... |
Optional | getAnnotation(Class> clazz, Class Returns the specified T annotation for the potentially annotated Class class if it exists. return Optional.ofNullable(clazz.getAnnotation(annotation));
|
T | getAnnotation(Class> clazz, Class This method scans the class and super-class hierarchy (up to, but not including java.lang.Object) for the specified annotation class. if (clazz.getName().equals(Object.class.getName())) { return null; T annotation = clazz.getAnnotation((Class<T>) annotationClass); if (annotation == null) { annotation = getAnnotation(clazz.getSuperclass(), annotationClass); return annotation; ... |
T | getAnnotation(Class> clazz, Class get Annotation T annotation = null; if (hasAnnotation(clazz, annotationClass)) { annotation = clazz.getAnnotation(annotationClass); return annotation; |
T | getAnnotation(Class> clazz, Class get Annotation T t = clazz.getAnnotation(annotationClass);
return t;
|
T | getAnnotation(Class> clazz, Class get Annotation T result = clazz.getAnnotation(annotationType); if (result == null) { Class<?> superclass = clazz.getSuperclass(); if (superclass != null) { return getAnnotation(superclass, annotationType); } else { return null; } else { return result; |
T | getAnnotation(Class> clazz, Class Retrieve an annotation from a possibly proxied CDI/Weld class. T an = clazz.getDeclaredAnnotation(annotationType); if (an == null && isProxy(clazz)) { an = clazz.getSuperclass().getDeclaredAnnotation(annotationType); return an; |
T | getAnnotation(Class> clazz, Class get Annotation Iterable<T> allAnnotations = Iterables.filter(getAnnotationsRecursive(clazz), annotationType); if (allAnnotations.iterator().hasNext()) { return allAnnotations.iterator().next(); return null; |
T | getAnnotation(Class> clazz, String fieldName, Class get Annotation try { Field field = clazz.getDeclaredField(fieldName); if (!field.isAccessible()) { field.setAccessible(true); return field.getAnnotation(annotationClass); } catch (NoSuchFieldException e) { return null; ... |
T | getAnnotation(Class> clazz, String name, Class>[] types, Class get Annotation if (clazz == null) { return null; try { Method method = clazz.getMethod(name, types); T annotation = method.getAnnotation(annotationType); if (annotation != null) { return annotation; ... |