Java Utililty Methods Reflection Annotation Find

List of utility methods to do Reflection Annotation Find

Description

The list of methods to do Reflection Annotation Find are organized into topic(s).

Method

AfindAnnotationInAnyParameter(Method method, Class annotationClass)
Tries to extract the first occurrence an annotation of a certain class inside a method's parameters.
for (Parameter parameter : method.getParameters()) {
    if (parameter.isAnnotationPresent(annotationClass)) {
        return parameter.getAnnotation(annotationClass);
return null;
AfindAnnotationInMethodOrInItsAnnotations(Method method, Class annotationClass)
Tries to extract an annotation of a certain class directly annotated on to the method or any of its annotations.
if (method.isAnnotationPresent(annotationClass)) {
    return method.getAnnotation(annotationClass);
for (Annotation annotation : method.getAnnotations()) {
    Class<? extends Annotation> annotationType = annotation.annotationType();
    if (annotationType.isAnnotationPresent(annotationClass)) {
        return annotationType.getAnnotation(annotationClass);
return null;
SetfindAnnotationMethods(String fullClassName, Class anno)
find Annotation Methods
Set<Method> methodSet = new HashSet<Method>();
Class<?> clz = Class.forName(fullClassName);
Method[] methods = clz.getDeclaredMethods();
for (Method method : methods) {
    if (method.getModifiers() != Modifier.PUBLIC) {
        continue;
    Annotation annotation = method.getAnnotation(anno);
...
LinkedHashMap,T>findAnnotationsMap(Class a, Class c)
Same as #findAnnotations(Class,Class) except returns the annotations as a map with the keys being the class on which the annotation was found.
LinkedHashMap<Class<?>, T> m = new LinkedHashMap<Class<?>, T>();
findAnnotationsMap(a, c, m);
return m;
AnnotationfindAnnotationSuperClasses(Class annotationClass, Class c)
find Annotation Super Classes
while (c != null) {
    Annotation result = c.getAnnotation(annotationClass);
    if (result != null)
        return result;
    else
        c = c.getSuperclass();
return null;
...
AnnotationfindAnnotationWithMetaAnnotation(Class clazz, Class metaAnnotationType)
find Annotation With Meta Annotation
Annotation annotation = getAnnotationWithMetaAnnotation(clazz, metaAnnotationType);
if (annotation != null) {
    return annotation;
for (Class<?> ifc : clazz.getInterfaces()) {
    annotation = findAnnotationWithMetaAnnotation(ifc, metaAnnotationType);
    if (annotation != null) {
        return annotation;
...