Java Reflection Method Annotation getMethods(Class clazz, Class annotation)

Here you can find the source of getMethods(Class clazz, Class annotation)

Description

get Methods

License

Open Source License

Declaration

public static Method[] getMethods(Class<?> clazz, Class<? extends Annotation> annotation) 

Method Source Code


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

import java.lang.annotation.Annotation;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static Method[] getMethods(Class<?> clazz, Class<? extends Annotation> annotation) {
        List<Method> methods = new ArrayList();
        for (Method m : clazz.getMethods()) {
            if (m.isAnnotationPresent(annotation)) {
                methods.add(m);//from w w  w .jav  a 2 s.  com
            }
        }
        return methods.toArray(new Method[0]);
    }
}

Related

  1. getMethodInClassWithAnnotation(Class cls, Class annotationClass, int... modifiers)
  2. getMethodLevelAnnotations(Class clazz, Class annotation)
  3. getMethodName(final Class annoType, final Class klazType)
  4. getMethodOrClassLevelAnnotation(Class annotationClass, Method method, Class clazz)
  5. getMethods(Annotation anno)
  6. getMethods(final Class clazz, final Class annotation)
  7. getMethods(final Class t, final Class a)
  8. getMethodsAnnotated(Class anno, Class holder)
  9. getMethodsAnnotatedBy(Class clazz, Class annotClass)