Here you can find the source of getAnnotationElementValue(AnnotatedElement annotatedElement, String annotationClassName, String annotationElementName, Class
public static <T> T getAnnotationElementValue(AnnotatedElement annotatedElement, String annotationClassName, String annotationElementName, Class<T> annotationElementType)
//package com.java2s; //License from project: Open Source License import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Method; public class Main { public static <T> T getAnnotationElementValue(AnnotatedElement annotatedElement, String annotationClassName, String annotationElementName, Class<T> annotationElementType) { final Annotation annotation = getAnnotation(annotatedElement, annotationClassName); return getAnnotationElementValue(annotation, annotationElementName, annotationElementType); }/* w w w . j a v a 2 s. c om*/ @SuppressWarnings("unchecked") public static <T> T getAnnotationElementValue(Annotation annotation, String annotationElementName, Class<T> annotationElementType) { try { if (annotation != null) { for (Method method : annotation.getClass().getMethods()) { if (method.getName().equals(annotationElementName)) { final Object value = method.invoke(annotation); if (annotationElementType.isInstance(value)) { return (T) value; } } } } return null; } catch (ReflectiveOperationException e) { throw new RuntimeException(e); } } public static Annotation getAnnotation(AnnotatedElement annotatedElement, String annotationClassName) { if (annotatedElement != null) { for (Annotation annotation : annotatedElement.getAnnotations()) { if (annotation.annotationType().getName().equals(annotationClassName)) { return annotation; } } } return null; } }