Here you can find the source of findAnnotation(Class> classy, Class extends Annotation> targetAnnotation)
static Annotation findAnnotation(Class<?> classy, Class<? extends Annotation> targetAnnotation)
//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; } }