Java examples for java.lang.annotation:Field Annotation
get Map Of Field Level Annotation From Class
import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Collections; import java.util.Map; public class Main{ public static Map<Field, Annotation[]> getMapOfFieldLevelAnnotationFromClass( Class annotationClass) { Map l = new HashMap(); Field[] fields = annotationClass.getDeclaredFields(); if (fields.length > 0) { for (Field f : fields) { Annotation[] a = f.getDeclaredAnnotations(); if (a.length > 0) { l.put(f, a);//from w w w .j a v a2s. c o m } } } return l; } }