code: private static Method findMethod(String methodName, Object instance, Class<?> valueClass, boolean setter)
                                                                                                               throws NoSuchMethodException {
          if (methodName == null) {
              return null;
          }
          
          int paramCount = setter ? 1 : 0;
          
          for (Method method : instance.getClass().getMethods()) {
              if (method.getName().equals(methodName) && method.getParameterTypes().length == paramCount) {
                  Class<?> targetClass = setter ? method.getParameterTypes()[0] : method.getReturnType();
                  
                  if (valueClass == null || TypeUtils.isAssignable(targetClass, valueClass)) {
                      return method;
                  }
              }
          }
          
          throw new NoSuchMethodException("Compatible method not found: " + methodName);
          
      }
docs: Returns the requested method from an object instance.
  
  @param methodName Name of the setter method.
  @param instance Object instance to search.
  @param valueClass The desired property return type (null if don't care).
  @param setter If true, search for setter method signature. If false, getter method signature.
  @return The requested method.
  @throws NoSuchMethodException If method was not found.