Java examples for java.lang.annotation:Method Annotation
get Map Of Method 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[]> getMapOfMethodLevelAnnotationFromClass( Class annotationClass) { Map m = new HashMap(); Method[] fields = annotationClass.getDeclaredMethods(); if (fields.length > 0) { for (Method f : fields) { Annotation[] a = f.getDeclaredAnnotations(); if (a.length > 0) { m.put(f, a);/*from ww w. java2s.co m*/ } } } return m; } }