code: Method getMethod(Class<?> type, Class<?> returnType, String name, Class<?>... parameters) {
          Method method = null;
          try {
              // first try for public methods
              method = type.getMethod(name, parameters);
              if (null != returnType && !returnType.isAssignableFrom(method.getReturnType())) {
                  method = null;
              }
          } catch (NoSuchMethodException nsme) {
              // ignore
              log.trace(nsme.getMessage(), nsme);
          }
          if (null == method) {
              method = getNonPublicMethod(type, returnType, name, parameters);
          }
          return method;
      }
docs: Get method with given name and parameters and given return type.
  
  @param type class on which method should be found
  @param returnType required return type (or null for void or no check)
  @param name method name
  @param parameters method parameter types
  @return method or null when method not found