List of utility methods to do Reflection Annotation Find
T | findAnnotation(AnnotatedElement annotated, Class find Annotation T ret; if (annotated == null) { ret = null; } else { ret = annotated.getAnnotation(annotationClass); return ret; |
A | findAnnotation(AnnotatedElement annotatedElement, Class annotationClass) Deep search of specified annotation considering "annotation inheritance" (annotation annotated with specified annotation). Objects.requireNonNull(annotatedElement); Objects.requireNonNull(annotationClass); A result = annotatedElement.getAnnotation(annotationClass); if (result != null) { return result; return findAnnotationInAnnotations(annotatedElement, annotationClass); |
A | findAnnotation(AnnotatedElement annotatedElement, Class annotationType) Searches for an annotation of a given type that's been applied to an element either directly (as a regular annotation) or indirectly (as a meta-annotations, i.e. if (annotationType == null) { return null; return findAnnotation(annotatedElement, annotationType, new HashSet<Annotation>()); |
T | findAnnotation(AnnotatedElement element, Class Find an annotation of given annotationType on the given element , considering that the given annotationType may be present as a meta annotation on any other annotation on that element. return (T) findAnnotation(element, annotationType.getName());
|
T | findAnnotation(Annotation parentAnnotation, Class Finds annotation of type specified in parameter, inside of other annotation. for (Annotation childAnnotation : parentAnnotation.annotationType().getAnnotations()) { if (childAnnotation.annotationType().equals(annotationType)) { return (T) childAnnotation; return null; |
T | findAnnotation(Annotation[] parameterAnnotations, Class Utility method to find if an annotation type is present in an array of annotations. for (int i = 0; i < parameterAnnotations.length; i++) { Annotation annotation = parameterAnnotations[i]; if (targetAnnotation.isInstance(annotation)) return targetAnnotation.cast(annotation); return null; |
T | findAnnotation(Annotation[] searchList, Class find Annotation if (searchList == null) { return null; for (Annotation ann : searchList) { if (ann.annotationType().equals(annotation)) { return (T) ann; return null; |
A | findAnnotation(Class clazz, Class annotationType) find Annotation A annotation = getAnnotation(clazz, annotationType); Class<?> cl = clazz; if (annotation == null) { annotation = searchOnInterfaces(clazz, annotationType, cl.getInterfaces()); while (annotation == null) { cl = cl.getSuperclass(); if (cl == null || cl == Object.class) { ... |
T | findAnnotation(Class clazz, Class find Annotation T annotation = (T) clazz.getAnnotation(annotationType); if (annotation != null) return annotation; Class clazzes[] = clazz.getInterfaces(); int len = clazzes.length; for (int i = 0; i < len; i++) { Class ifc = clazzes[i]; annotation = findAnnotation(ifc, annotationType); ... |
Annotation | findAnnotation(Class> aClass, Class extends Annotation> annotationClass) Finds an annotation of the class aClass by looking for an annotation matching the class annotationClass for (Annotation annotation : aClass.getAnnotations()) { if (annotation.annotationType().equals(annotationClass)) { return annotation; return null; |