private static void addMethodWithBestPosition(Method method, List<Method> methods) {
        int index = -1;
        for (int i = 0; i < methods.size(); i++) {
            Method m = methods.get(i);
            if (m.getName().equals(method.getName())) {
                if (m.getParameters().size() <= method.getParameters().size()) {
                    index = i + 1;
                } else {
                    index = i;
                }
            } else if (m.getName().startsWith(method.getName())) {
                if (index == -1) {
                    index = i;
                }
            } else if (method.getName().startsWith(m.getName())) {
                index = i + 1;
            }
        }
        if (index == -1 || index >= methods.size()) {
            methods.add(methods.size(), method);
        } else {
            methods.add(index, method);
        }
    }
private static void addMethodWithBestPosition(Method method, List<Method> methods) {
        int index = -1;
        for (int i = 0; i < methods.size(); i++) {
            Method m = methods.get(i);
            if (m.getName().equals(method.getName())) {
                if (m.getParameters().size() <= method.getParameters().size()) {
                    index = i + 1;
                } else {
                    index = i;
                }
            } else if (m.getName().startsWith(method.getName())) {
                if (index == -1) {
                    index = i;
                }
            } else if (method.getName().startsWith(m.getName())) {
                index = i + 1;
            }
        }
        if (index == -1 || index >= methods.size()) {
            methods.add(methods.size(), method);
        } else {
            methods.add(index, method);
        }
    }
private static void addMethodWithBestPosition ( Method method , List < Method > methods ) { int index = - 1 ; for ( int i = 0 ; i < methods . size ( ) ; i ++ ) { Method m = methods . get ( i ) ; if ( m . getName ( ) . equals ( method . getName ( ) ) ) { if ( m . getParameters ( ) . size ( ) <= method . getParameters ( ) . size ( ) ) { index = i + 1 ; } else { index = i ; } } else if ( m . getName ( ) . startsWith ( method . getName ( ) ) ) { if ( index == - 1 ) { index = i ; } } else if ( method . getName ( ) . startsWith ( m . getName ( ) ) ) { index = i + 1 ; } } if ( index == - 1 || index >= methods . size ( ) ) { methods . add ( methods . size ( ) , method ) ; } else { methods . add ( index , method ) ; } }
获取最佳添加位置
@param method
@param methods
@return
获取最佳添加位置