Java Reflection Annotation getAnnotation(Class cls, Method... methods)

Here you can find the source of getAnnotation(Class cls, Method... methods)

Description

get Annotation

License

Open Source License

Declaration

public static <T extends Annotation> T getAnnotation(Class<T> cls, Method... methods) 

Method Source Code


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

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

public class Main {
    public static <T extends Annotation> T getAnnotation(Class<T> cls, Method... methods) {
        T annotation = null;/*from w  ww. j  a v a2  s.  c om*/
        for (Method method : methods) {
            if (method != null && (annotation = method.getAnnotation(cls)) != null) {
                return annotation;
            }
        }
        return null;
    }
}

Related

  1. getAnnotation(Class annotationClass, Class cls)
  2. getAnnotation(Class annotationType, AnnotatedElement... objects)
  3. getAnnotation(Class cl, Object o)
  4. getAnnotation(Class clazz, Method method, int parameterIndex)
  5. getAnnotation(Class cls, Annotation... annotations)
  6. getAnnotation(Class lookingFor, Annotation[] annotations)
  7. getAnnotation(Enum enumConstant, Class annotationClass)
  8. getAnnotation(final AnnotatedElement annotatedElement, final Class annotationClass)
  9. getAnnotation(final Class c, final Class annClass)