Java Reflection Method Annotation getMethods(final Class t, final Class a)

Here you can find the source of getMethods(final Class t, final Class a)

Description

get Methods

License

Open Source License

Declaration

public static final List<Method> getMethods(final Class<?> t, final Class<? extends Annotation> a) 

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 final List<Method> getMethods(final Class<?> t, final Class<? extends Annotation> a) {
        final List<Method> ms = new ArrayList<Method>();
        Class<?> c = t;/*  w  ww  . ja  va  2s.c o m*/
        while (c != null && c != Object.class) {
            for (final Method m : c.getDeclaredMethods())
                if (m.isAnnotationPresent(a)) {
                    m.setAccessible(true);
                    ms.add(m);
                }
            c = c.getSuperclass();
        }
        return ms;
    }
}

Related

  1. getMethodName(final Class annoType, final Class klazType)
  2. getMethodOrClassLevelAnnotation(Class annotationClass, Method method, Class clazz)
  3. getMethods(Annotation anno)
  4. getMethods(Class clazz, Class annotation)
  5. getMethods(final Class clazz, final Class annotation)
  6. getMethodsAnnotated(Class anno, Class holder)
  7. getMethodsAnnotatedBy(Class clazz, Class annotClass)
  8. getMethodsAnnotatedWith(Class owner, Class annotationClass, boolean includeSuper)
  9. getMethodsAnnotatedWith(Class clazz, Class annotClazz)