jetbrick-commons/src/main/java/jetbrick/reflect/ExecutableUtils.java
public static <T extends Executable> T searchExecutable(List<T> executables, String name, Class<?>... parameterTypes) {
        T best = null;
        Class<?>[] bestParametersTypes = null;

        for (T execute : executables) {
            if (name != null && !execute.getName().equals(name)) continue;

            Class<?>[] types = execute.getParameterTypes();
            if (isParameterTypesCompatible(types, parameterTypes, execute.isVarArgs(), false)) {
                // 可能有多个方法与实际参数类型兼容。采用就近兼容原则。
                if (best == null) {
                    best = execute;
                    bestParametersTypes = types;
                } else if (best.isVarArgs() && (!execute.isVarArgs())) {
                    best = execute; // 不可变参数的函数优先
                    bestParametersTypes = types;
                } else if ((!best.isVarArgs()) && execute.isVarArgs()) {
                    // no change
                } else {
                    if (isParameterTypesCompatible(bestParametersTypes, types, best.isVarArgs(), execute.isVarArgs())) {
                        best = execute;
                        bestParametersTypes = types;
                    }
                }
            }
        }
        return best;
    }
public static <T extends Executable> T searchExecutable(List<T> executables, String name, Class<?>... parameterTypes) {
        T best = null;
        Class<?>[] bestParametersTypes = null;

        for (T execute : executables) {
            if (name != null && !execute.getName().equals(name)) continue;

            Class<?>[] types = execute.getParameterTypes();
            if (isParameterTypesCompatible(types, parameterTypes, execute.isVarArgs(), false)) {
                // 可能有多个方法与实际参数类型兼容。采用就近兼容原则。
                if (best == null) {
                    best = execute;
                    bestParametersTypes = types;
                } else if (best.isVarArgs() && (!execute.isVarArgs())) {
                    best = execute; // 不可变参数的函数优先
                    bestParametersTypes = types;
                } else if ((!best.isVarArgs()) && execute.isVarArgs()) {
                    // no change
                } else {
                    if (isParameterTypesCompatible(bestParametersTypes, types, best.isVarArgs(), execute.isVarArgs())) {
                        best = execute;
                        bestParametersTypes = types;
                    }
                }
            }
        }
        return best;
    }
查找最佳匹配的方法或者构造函数。

@param executables - 带查找的 list
@param name - 方法名称(如果查找构造函数，那么name可以是null)
@param parameterTypes － 方法或者构造函数参数(支持类型转换)
@return 找到的方法或者构造函数，找不到返回 null.