List of utility methods to do Reflection Annotation
V | getAnnotationValue(final A annotation, final Function valueRetriever, final V defaultValue) Returns the value of the given annotation using a Function. if (annotation != null) { final V value = valueRetriever.apply(annotation); if (defaultValue.getClass().equals(String.class) && !String.class.cast(value).isEmpty()) { return value; } else if (!defaultValue.getClass().equals(String.class) && value != null) { return value; return defaultValue; |
Object | getAnnotationValue(Object aObj, String aValue) Get annotation value of annotation object via reflection return aObj.getClass().getMethod(aValue).invoke(aObj);
|
Object | getAnnotationValue(Object obj, Class extends Annotation> annotation, String field) Retrieve the value of the annotation Class<?> cls = getClass(obj); if (cls.isAnnotationPresent(annotation)) return invokeMethod(cls.getAnnotation(annotation), field); else return null; |
Object | getAnnotationWithinHierarchy(Class> fsmClass, Class aggregateClass) Get annotation within hierarchy while (fsmClass != null) { if (getAnnotation(fsmClass, aggregateClass) != null) { return getAnnotation(fsmClass, aggregateClass); fsmClass = fsmClass.getSuperclass(); return null; |
Annotation | getAnnotationWithMetaAnnotation(AnnotatedElement annotatedElement, Class extends Annotation> metaAnnotationType) get Annotation With Meta Annotation Annotation[] annotations = annotatedElement.getAnnotations(); for (Annotation annotation : annotations) { Class<? extends Annotation> annotationClass = annotation.annotationType(); if (annotationClass.isAnnotationPresent(metaAnnotationType)) { return annotation; return null; ... |