ControllerUtils { static boolean isRequestMethod(Method method) { if (hasDeclaredRequestMethodAnnotation(method)) { return true; } if (AnnotationUtils.hasMvcOrJaxrsAnnotations(method)) { return false; } Class<?> clazz = method.getDeclaringClass(); while (clazz != null) { try { Method currentMethod = clazz.getMethod(method.getName(), method.getParameterTypes()); if (hasDeclaredRequestMethodAnnotation(currentMethod)) { return true; } } catch (NoSuchMethodException ignored) { } clazz = clazz.getSuperclass(); } for (Class<?> in : method.getDeclaringClass().getInterfaces()) { try { Method currentMethod = in.getMethod(method.getName(), method.getParameterTypes()); if (hasDeclaredRequestMethodAnnotation(currentMethod)) { return true; } } catch (NoSuchMethodException ignored) { } } return false; } private  ControllerUtils(); static boolean isController(Class<?> clazz); static boolean isControllerMethod(Method method);  }
@Test public void shouldIdentifyRequestMethods() throws NoSuchMethodException { assertThat(ControllerUtils.isRequestMethod(NoController.class.getMethod("foo")), is(false)); assertThat(ControllerUtils.isRequestMethod(NoController.class.getMethod("bar")), is(true)); assertThat(ControllerUtils.isRequestMethod(InheritedController.class.getMethod("foo")), is(false)); assertThat(ControllerUtils.isRequestMethod(InheritedController.class.getMethod("bar")), is(true)); assertThat(ControllerUtils.isRequestMethod(ControllerImpl.class.getMethod("foo")), is(true)); assertThat(ControllerUtils.isRequestMethod(InheritedController.class.getMethod("baz")), is(false)); assertThat(ControllerUtils.isRequestMethod(ControllerImpl.class.getMethod("baz")), is(false)); }