code: private Method verifyThatControllerAndMethodExists(Class<?> controller,
                                                         String controllerMethod) throws NoSuchMethodException {
  
          Method methodFromQueryingClass = null;
  
          // 1. Make sure method is in class
          // 2. Make sure only one method is there. Otherwise we cannot really
          // know what to do with the parameters.
          for (Method method : controller.getMethods()) {
  
              if (method.getName().equals(controllerMethod)) {
                  if (methodFromQueryingClass == null) {
                      methodFromQueryingClass = method;
                  } else {
                      throw new NoSuchMethodException();
                  }
              }
  
          }
  
          if (methodFromQueryingClass == null) {
              throw new NoSuchMethodException("The method " + controllerMethod + " does not exist in " + controller.getName());
          }
  
          // make sure that the return type of that controller method
          // is of type Result.
          if (methodFromQueryingClass.getReturnType().isAssignableFrom(Result.class)) {
              return methodFromQueryingClass;
          } else {
              throw new NoSuchMethodException("The method " + controllerMethod + " is declared in " + controller
                      .getName() + " but does not return a " + Result.class.getName() + " object.");
          }
      }
docs: Checks that the action method really exists.
  
  @param controller       the controller object
  @param controllerMethod the method name
  @return the Method object.
  @throws NoSuchMethodException if the action method does not exist in the given controller object.