Java Utililty Methods Reflection Method Annotation

List of utility methods to do Reflection Method Annotation

Description

The list of methods to do Reflection Method Annotation are organized into topic(s).

Method

Method[]getMethodsWithAnnotation(Class clazz, Class annotationType)
get Methods With Annotation
List<Method> result = new ArrayList<Method>();
for (Class<?> c = clazz; c != null; c = c.getSuperclass()) {
    for (Method method : c.getMethods()) {
        if (method.getAnnotation(annotationType) != null && !contains(result, method)) {
            result.add(method);
return result.toArray(new Method[0]);
ListgetMethodsWithAnnotation(Class type, Class annotation, boolean checkSuper)
Gets a list of all methods within a class that are marked with an annotation.
List<Method> methods = new ArrayList<>();
Class<?> clazz = type;
while (clazz != Object.class) {
    for (Method method : clazz.getDeclaredMethods()) {
        if (method.isAnnotationPresent(annotation)) {
            methods.add(method);
    if (!checkSuper) {
        break;
    clazz = clazz.getSuperclass();
return methods;
ListgetMethodsWithAnnotation(final Class clazz, final Class... annotationClasses)
Get all the methods of this object and its superclasses that are annotated with this annotation.
final List<Method> result = new ArrayList<Method>();
final List<Method> methods = getMethods(clazz);
for (final Method m : methods) {
    if (isAnnotationPresent(m.getAnnotations(), annotationClasses))
        result.add(m);
return result;
Map>getMethodValue(Class annotationClasss, Class targetClass, String... annotationFields)
get Method Value
Map<String, Map<String, Object>> map = new HashMap<String, Map<String, Object>>(20);
Method[] methods = targetClass.getDeclaredMethods();
for (Method method : methods) {
    if (method.isAnnotationPresent(annotationClasss)) {
        Map<String, Object> methodMap = new HashMap<String, Object>(10);
        Annotation p = method.getAnnotation(annotationClasss);
        for (String annotationField : annotationFields) {
            Method m = p.getClass().getDeclaredMethod(annotationField);
...