code: public static Method findMatchingMethod(Class<?> classToInspect, Class<?> returnType, Object... params) {
          Method[] methods = classToInspect.getMethods();
          Method checkedMethod = null;
          for (Method method : methods) {
              Type[] parameterTypes = method.getParameterTypes();
              // if the return type is not specified (i.e null) we only check the parameters
              boolean matchReturnType = returnType == null || returnType.equals(method.getReturnType());
  
              if (checkParams(parameterTypes, params) && matchReturnType) {
                  if (checkedMethod == null) {
                      checkedMethod = method;
                  } else {
                      throw BusinessException.createNew(BusinessErrorCode.AMBIGUOUS_METHOD_FOUND)
                              .put("method1", method)
                              .put("method2", checkedMethod)
                              .put("object", classToInspect.getSimpleName())
                              .put("parameters", params);
                  }
              }
          }
          return checkedMethod;
      }
docs: Finds a method matching the given parameters and return type.