Java Reflection Annotation getAnnotation(Annotation[] annotations, Class clazz)

Here you can find the source of getAnnotation(Annotation[] annotations, Class clazz)

Description

get Annotation

License

Open Source License

Declaration

public static <T extends Annotation> T getAnnotation(Annotation[] annotations, Class<T> clazz) 

Method Source Code

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

import java.lang.annotation.Annotation;

public class Main {
    public static <T extends Annotation> T getAnnotation(Annotation[] annotations, Class<T> clazz) {
        for (Annotation annotation : annotations)
            if (clazz.isAssignableFrom(annotation.getClass()))
                return clazz.cast(annotation);

        return null;
    }/*  w  ww  .jav  a 2s.c  om*/
}

Related

  1. getAnnotation(Annotation ann, Class annotationType)
  2. getAnnotation(Annotation[] annotaions, Class T)
  3. getAnnotation(Annotation[] annotations, Class annotationType)
  4. getAnnotation(Annotation[] annotations, Class annotationClazz)
  5. getAnnotation(Annotation[] annotations, Class annotationType)
  6. getAnnotation(Class clazz, Class annotation)
  7. getAnnotation(Class cls, Class annotationCls)
  8. getAnnotation(Class cls, Class annotationCls)
  9. getAnnotation(Class theExaminedClass, Class theExpectedAnnotation)