@@ -0,0 +1,2869 @@
+package org.jeecqrs.common.util;%0A%0Aimport java.lang.annotation.Annotation;%0Aimport java.lang.reflect.Method;%0Aimport java.util.Arrays;%0A%0A/**%0A * Provides utility methods for reflection.%0A */%0Apublic class ReflectionUtils %7B%0A    %0A%0A    /**%0A     * Finds the unique method with the given annotation on the given class or%0A     * any of its super classes.%0A     * Also sets the method accessible.%0A     * Throws a runtime exception if no method with this annotation can be%0A     * found or if the annotated method has a different signature.%0A     * %0A     * @param clazz  the class to search%0A     * @param annotation  the annotation to find%0A     * @param params  the required method parameters%0A     * @return   the method%0A     */%0A    public static Method findUniqueMethod(%0A            Class%3C?%3E clazz,%0A            Class%3C? extends Annotation%3E annotation,%0A            Object%5B%5D params) %7B%0A        Method m = findAnnotatedMethodOrFail(clazz, annotation);%0A        if (!Arrays.deepEquals(params, m.getParameterTypes())) %7B%0A            String msg = String.format(%0A                    %22Method annotated with @%25s has wrong signature, required %25s, but is %25s%22,%0A                    annotation.getCanonicalName(), params, m);%0A            throw new IllegalArgumentException(msg);%0A        %7D%0A        m.setAccessible(true);%0A        return m;%0A    %7D%0A%0A    /**%0A     * Finds the unique method with the given annotation or throws%0A     * a %7B@link RuntimeException%7D if no such method can be found on the%0A     * class or any of its super classes.%0A     * %0A     * @param clazz  the class to search%0A     * @param annotation  the annotation to find%0A     * @return   the method%0A     */%0A    public static Method findAnnotatedMethodOrFail(Class%3C?%3E clazz, Class%3C? extends Annotation%3E annotation) %7B%0A        Method m = findAnnotatedMethod(clazz, annotation);%0A        if (m == null) %7B%0A            String msg = String.format(%0A                    %22Neither class %25s nor any of its super classes provide a method annotated with @%25s%22,%0A                    clazz.getCanonicalName(), annotation.getCanonicalName());%0A            throw new IllegalStateException(msg);%0A        %7D%0A        return m;%0A    %7D%0A%0A    /**%0A     * Finds the first method with the given annotation on the given%0A     * class or any of its super classes.%0A     * %0A     * @param clazz  the class to search%0A     * @param annotation  the annotation to find%0A     * @return   the method or null if no such method exists%0A     */%0A    public static Method findAnnotatedMethod(Class%3C?%3E clazz, Class%3C? extends Annotation%3E annotation) %7B%0A        Class%3C?%3E current = clazz;%0A        while (current != Object.class) %7B%0A            Method%5B%5D methods = current.getDeclaredMethods();%0A            for (Method m : methods)%0A                if (m.isAnnotationPresent(annotation))%0A                    return m;%0A            current = current.getSuperclass();%0A        %7D%0A        return null;%0A    %7D%0A%0A%7D%0A

Add ReflectionUtils to search for methods