Java Reflection Annotation Find findAnnotationMethods(String fullClassName, Class anno)

Here you can find the source of findAnnotationMethods(String fullClassName, Class anno)

Description

find Annotation Methods

License

Open Source License

Declaration

public static Set<Method> findAnnotationMethods(String fullClassName, Class<? extends Annotation> anno)
        throws ClassNotFoundException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;

public class Main {

    public static Set<Method> findAnnotationMethods(String fullClassName, Class<? extends Annotation> anno)
            throws ClassNotFoundException {
        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;
            }//from w  ww. jav  a2s . c o  m
            Annotation annotation = method.getAnnotation(anno);
            if (annotation != null) {
                methodSet.add(method);
            }
        }
        return methodSet;
    }
}

Related

  1. findAnnotationHelper( Class base, Type iface)
  2. findAnnotationIn(List modifiers, Class clazz)
  3. findAnnotationInAnnotations(AnnotatedElement annotatedElement, Class annotationClass)
  4. findAnnotationInAnyParameter(Method method, Class annotationClass)
  5. findAnnotationInMethodOrInItsAnnotations(Method method, Class annotationClass)
  6. findAnnotationsMap(Class a, Class c)
  7. findAnnotationSuperClasses(Class annotationClass, Class c)
  8. findAnnotationWithMetaAnnotation(Class clazz, Class metaAnnotationType)