Java Reflection Method Annotation getMethods(Annotation anno)

Here you can find the source of getMethods(Annotation anno)

Description

get Methods

License

Open Source License

Declaration

public static Method[] getMethods(Annotation anno) 

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.ArrayList;

public class Main {
    public static Method[] getMethods(Annotation anno) {
        ArrayList<Method> methods = new ArrayList<Method>();
        Class<? extends Annotation> cls = anno.annotationType();
        for (Method method : cls.getDeclaredMethods()) {
            if (Modifier.isPublic(method.getModifiers()) && method.getDeclaringClass() == cls) {
                methods.add(method);/* w w  w  . ja  va2 s  .  c  o  m*/
            }
        }
        return methods.toArray(new Method[methods.size()]);
    }
}

Related

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