common_helper/src/main/java/com/xiongyingqi/util/MethodInvoker.java
protected Method findMatchingMethod() {
        String targetMethod = getTargetMethod();
        Object[] arguments = getArguments();
        int argCount = arguments.length;

        Method[] candidates = ReflectionUtils.getAllDeclaredMethods(getTargetClass());
        int minTypeDiffWeight = Integer.MAX_VALUE;
        Method matchingMethod = null;

        for (Method candidate : candidates) {
            if (candidate.getName().equals(targetMethod)) {
                Class<?>[] paramTypes = candidate.getParameterTypes();
                if (paramTypes.length == argCount) {
                    int typeDiffWeight = getTypeDifferenceWeight(paramTypes, arguments);
                    if (typeDiffWeight < minTypeDiffWeight) {
                        minTypeDiffWeight = typeDiffWeight;
                        matchingMethod = candidate;
                    }
                }
            }
        }

        return matchingMethod;
    }
protected Method findMatchingMethod() {
        String targetMethod = getTargetMethod();
        Object[] arguments = getArguments();
        int argCount = arguments.length;

        Method[] candidates = ReflectionUtils.getAllDeclaredMethods(getTargetClass());
        int minTypeDiffWeight = Integer.MAX_VALUE;
        Method matchingMethod = null;

        for (Method candidate : candidates) {
            if (candidate.getName().equals(targetMethod)) {
                Class<?>[] paramTypes = candidate.getParameterTypes();
                if (paramTypes.length == argCount) {
                    int typeDiffWeight = getTypeDifferenceWeight(paramTypes, arguments);
                    if (typeDiffWeight < minTypeDiffWeight) {
                        minTypeDiffWeight = typeDiffWeight;
                        matchingMethod = candidate;
                    }
                }
            }
        }

        return matchingMethod;
    }
protected Method findMatchingMethod ( ) { String targetMethod = getTargetMethod ( ) ; Object [ ] arguments = getArguments ( ) ; int argCount = arguments . length ; Method [ ] candidates = ReflectionUtils . getAllDeclaredMethods ( getTargetClass ( ) ) ; int minTypeDiffWeight = Integer . MAX_VALUE ; Method matchingMethod = null ; for ( Method candidate : candidates ) { if ( candidate . getName ( ) . equals ( targetMethod ) ) { Class < ? > [ ] paramTypes = candidate . getParameterTypes ( ) ; if ( paramTypes . length == argCount ) { int typeDiffWeight = getTypeDifferenceWeight ( paramTypes , arguments ) ; if ( typeDiffWeight < minTypeDiffWeight ) { minTypeDiffWeight = typeDiffWeight ; matchingMethod = candidate ; } } } } return matchingMethod ; }
Find a matching method with the specified name for the specified arguments.

@return a matching method, or {@code null} if none
@see #getTargetClass()
@see #getTargetMethod()
@see #getArguments()
Find a matching method with the specified name for the specified arguments .