Here you can find the source of getAnnotationByType(AnnotatedElement element, Class annotationType)
public static Annotation getAnnotationByType(AnnotatedElement element, Class annotationType)
//package com.java2s; //License from project: Open Source License import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; public class Main { public static Annotation getAnnotationByType(AnnotatedElement element, Class annotationType) { Annotation[] annotations = element.getAnnotations(); for (Annotation annotation : annotations) { if (annotation.annotationType().equals(annotationType)) { return annotation; }/*from w w w . j a v a 2s. com*/ } return null; } }