@Test public void test_applicability_empty() { Class[] args = {}; Class[] params = args; JavaSignatureComparator jsCmp = new JavaSignatureComparator(args); int appl = jsCmp.applicability(params, false); assertThat(appl, is(JavaSignatureComparator.MATCH)); }
public int applicability(final Class<?>[] paramTypes, boolean varArgs) { if (argTypes == null) { return MATCH_WILDCARD; } int level = MATCH; final int fixArgs = paramTypes.length - (varArgs ? 1 : 0); if (fixArgs > argTypes.length || (!varArgs && fixArgs != argTypes.length)) { return NO_MATCH; } for (int i = 0; i < fixArgs; i++) { int m = applicable(argTypes[i], paramTypes[i]); if (m == NO_MATCH) return NO_MATCH; if (m < level) level = m; } if (varArgs) { Class<?> varArgType = paramTypes[fixArgs]; if (paramTypes.length == argTypes.length) { int m = applicable(argTypes[fixArgs], varArgType); if (m != NO_MATCH) { return Math.min(m, level); } } level = MATCH_VARARGS; Class<?> comp = varArgType.getComponentType(); for (int i = fixArgs; i < argTypes.length; i++) { int m = applicable(argTypes[i], comp); if (m == NO_MATCH) return NO_MATCH; } } return level; }
JavaSignatureComparator { public int applicability(final Class<?>[] paramTypes, boolean varArgs) { if (argTypes == null) { return MATCH_WILDCARD; } int level = MATCH; final int fixArgs = paramTypes.length - (varArgs ? 1 : 0); if (fixArgs > argTypes.length || (!varArgs && fixArgs != argTypes.length)) { return NO_MATCH; } for (int i = 0; i < fixArgs; i++) { int m = applicable(argTypes[i], paramTypes[i]); if (m == NO_MATCH) return NO_MATCH; if (m < level) level = m; } if (varArgs) { Class<?> varArgType = paramTypes[fixArgs]; if (paramTypes.length == argTypes.length) { int m = applicable(argTypes[fixArgs], varArgType); if (m != NO_MATCH) { return Math.min(m, level); } } level = MATCH_VARARGS; Class<?> comp = varArgType.getComponentType(); for (int i = fixArgs; i < argTypes.length; i++) { int m = applicable(argTypes[i], comp); if (m == NO_MATCH) return NO_MATCH; } } return level; } }
JavaSignatureComparator { public int applicability(final Class<?>[] paramTypes, boolean varArgs) { if (argTypes == null) { return MATCH_WILDCARD; } int level = MATCH; final int fixArgs = paramTypes.length - (varArgs ? 1 : 0); if (fixArgs > argTypes.length || (!varArgs && fixArgs != argTypes.length)) { return NO_MATCH; } for (int i = 0; i < fixArgs; i++) { int m = applicable(argTypes[i], paramTypes[i]); if (m == NO_MATCH) return NO_MATCH; if (m < level) level = m; } if (varArgs) { Class<?> varArgType = paramTypes[fixArgs]; if (paramTypes.length == argTypes.length) { int m = applicable(argTypes[fixArgs], varArgType); if (m != NO_MATCH) { return Math.min(m, level); } } level = MATCH_VARARGS; Class<?> comp = varArgType.getComponentType(); for (int i = fixArgs; i < argTypes.length; i++) { int m = applicable(argTypes[i], comp); if (m == NO_MATCH) return NO_MATCH; } } return level; } JavaSignatureComparator(Class<?>... argTypes); }
JavaSignatureComparator { public int applicability(final Class<?>[] paramTypes, boolean varArgs) { if (argTypes == null) { return MATCH_WILDCARD; } int level = MATCH; final int fixArgs = paramTypes.length - (varArgs ? 1 : 0); if (fixArgs > argTypes.length || (!varArgs && fixArgs != argTypes.length)) { return NO_MATCH; } for (int i = 0; i < fixArgs; i++) { int m = applicable(argTypes[i], paramTypes[i]); if (m == NO_MATCH) return NO_MATCH; if (m < level) level = m; } if (varArgs) { Class<?> varArgType = paramTypes[fixArgs]; if (paramTypes.length == argTypes.length) { int m = applicable(argTypes[fixArgs], varArgType); if (m != NO_MATCH) { return Math.min(m, level); } } level = MATCH_VARARGS; Class<?> comp = varArgType.getComponentType(); for (int i = fixArgs; i < argTypes.length; i++) { int m = applicable(argTypes[i], comp); if (m == NO_MATCH) return NO_MATCH; } } return level; } JavaSignatureComparator(Class<?>... argTypes); Class<?>[] getReferenceSignature(); int compareSpecificness(final Class<?>[] a, boolean a_varArgs, final Class<?>[] b, boolean b_varArgs); int applicability(final Class<?>[] paramTypes, boolean varArgs); }
JavaSignatureComparator { public int applicability(final Class<?>[] paramTypes, boolean varArgs) { if (argTypes == null) { return MATCH_WILDCARD; } int level = MATCH; final int fixArgs = paramTypes.length - (varArgs ? 1 : 0); if (fixArgs > argTypes.length || (!varArgs && fixArgs != argTypes.length)) { return NO_MATCH; } for (int i = 0; i < fixArgs; i++) { int m = applicable(argTypes[i], paramTypes[i]); if (m == NO_MATCH) return NO_MATCH; if (m < level) level = m; } if (varArgs) { Class<?> varArgType = paramTypes[fixArgs]; if (paramTypes.length == argTypes.length) { int m = applicable(argTypes[fixArgs], varArgType); if (m != NO_MATCH) { return Math.min(m, level); } } level = MATCH_VARARGS; Class<?> comp = varArgType.getComponentType(); for (int i = fixArgs; i < argTypes.length; i++) { int m = applicable(argTypes[i], comp); if (m == NO_MATCH) return NO_MATCH; } } return level; } JavaSignatureComparator(Class<?>... argTypes); Class<?>[] getReferenceSignature(); int compareSpecificness(final Class<?>[] a, boolean a_varArgs, final Class<?>[] b, boolean b_varArgs); int applicability(final Class<?>[] paramTypes, boolean varArgs); static final int MATCH; static final int MATCH_WILDCARD; static final int MATCH_BOXING; static final int MATCH_VARARGS; static final int NO_MATCH; }