ReflectionUtils { public static List<Method> getAllDeclaredMethodsAnnotatedWith(Class<?> type, Class<? extends Annotation> annotationType) { List<Method> methods = ReflectionUtils.getAllDeclaredMethods(type); filterByAnnotationType(methods, annotationType); return methods; } private  ReflectionUtils(); static List<Method> findMethods(Class<?> clazz, String nameRegex,
            ParamCount numberOfParams); static List<Method> findMethods(Class<?> clazz, String nameRegex,
            Class<?>... paramTypes); static boolean isComponent(Class<?> componentClass); static List<Field> getAllDeclaredFields(Class<?> type); static List<Field> getAllDeclaredFieldsAnnotatedWith(Class<?> type,
            Class<? extends Annotation> annotationType); static List<Method> getAllDeclaredMethods(Class<?> type); static List<Method> getAllDeclaredMethodsAnnotatedWith(Class<?> type,
            Class<? extends Annotation> annotationType);  }
@Test public void test_getAllDeclaredMethodsFromBaseClassByAnnotation() { List<Method> methods = getAllDeclaredMethodsAnnotatedWith( BaseClassToExamine.class, UiHandler.class); assertEquals(1, methods.size()); assertEquals("onValueChangedBase", methods.get(0).getName()); }
@Test public void test_getAllDeclaredMethodsFromSubClassByAnnotation() { List<Method> methods = getAllDeclaredMethodsAnnotatedWith( SubClassToExamine.class, UiDataSource.class); assertEquals(2, methods.size()); Collections.sort(methods, new MethodByNameComparator()); assertEquals("getDataFromBase", methods.get(0).getName()); assertEquals("getDataFromSub", methods.get(1).getName()); }