Java Reflection Annotation getAnnotation(Class cls, Class annotation)

Here you can find the source of getAnnotation(Class cls, Class annotation)

Description

get Annotation

License

Open Source License

Declaration

public static <T extends Annotation> T getAnnotation(Class<?> cls, Class<T> annotation) 

Method Source Code


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

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

public class Main {
    public static <T extends Annotation> T getAnnotation(Class<?> cls, Class<T> annotation) {
        return cls.getAnnotation(annotation);
    }//from ww  w.  j  a  v a 2s  .c om

    public static <T extends Annotation> T getAnnotation(Method method, Class<T> annotation) {
        return method.getAnnotation(annotation);
    }
}

Related

  1. getAnnotation(Class clazz, Class annotationType)
  2. getAnnotation(Class clazz, Class annotationType)
  3. getAnnotation(Class clazz, String fieldName, Class annotationClass)
  4. getAnnotation(Class clazz, String name, Class[] types, Class annotationType)
  5. getAnnotation(Class cls, Class annotationClass)
  6. getAnnotation(Class componentClass, Class annotationClass)
  7. getAnnotation(Class configInterface, Method method, Class annotationType, boolean searchMethodType)
  8. getAnnotation(Class klazz, Class annotationClass)
  9. getAnnotation(Class objectClass, Class annotationClass)