Here you can find the source of getAnnotation(Annotation[] annotations, Class
public static <T extends Annotation> T getAnnotation(Annotation[] annotations, Class<T> clazz)
//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*/ }