Java Reflection Annotation Find findAnnotation(Class classy, Class targetAnnotation)

Here you can find the source of findAnnotation(Class classy, Class targetAnnotation)

Description

find Annotation

License

Open Source License

Declaration

static Annotation findAnnotation(Class<?> classy, Class<? extends Annotation> targetAnnotation) 

Method Source Code


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

import java.lang.annotation.Annotation;

public class Main {
    static Annotation findAnnotation(Class<?> classy, Class<? extends Annotation> targetAnnotation) {
        Annotation[] annotations = classy.getAnnotations();
        for (Annotation annotation : annotations) {
            if (targetAnnotation.isInstance(annotation)) {
                return annotation;
            }/*from w  ww  . j  ava2 s  . c om*/
        }
        return null;
    }
}

Related

  1. findAnnotation(Annotation[] parameterAnnotations, Class targetAnnotation)
  2. findAnnotation(Annotation[] searchList, Class annotation)
  3. findAnnotation(Class clazz, Class annotationType)
  4. findAnnotation(Class clazz, Class annotationType)
  5. findAnnotation(Class aClass, Class annotationClass)
  6. findAnnotation(Class clazz, Class annotationClass, Set> set)
  7. findAnnotation(Class clazz, Class annotationClass)
  8. findAnnotation(Class clazz, Class annotationType)
  9. findAnnotation(Class clazz, Class annotationType)