Java tutorial
//package com.java2s; import java.lang.annotation.Annotation; import java.lang.reflect.Field; public class Main { public static <A extends Annotation> A getAnnotation(Field field, Class<A> clazz) { A result = null; if (field != null && clazz != null) { result = field.getAnnotation(clazz); } return result; } public static <A extends Annotation> A getAnnotation(Class<?> cla, Class<A> clazz) { A result = null; if (cla != null && clazz != null) { result = cla.getAnnotation(clazz); } return result; } }