@Test public void findArgTypeMatch1() { FormulaFunction function1 = mock(FormulaFunction.class); when(function1.isVarArgs()).thenReturn(false); when(function1.getArgumentTypes()).thenReturn(Arrays.<Class<?>>asList(String.class)); FormulaFunction function2 = mock(FormulaFunction.class); when(function2.isVarArgs()).thenReturn(true); when(function2.getArgumentTypes()).thenReturn(Arrays.<Class<?>>asList(Number.class)); List<FormulaFunction> functions = Arrays.asList(function1, function2); assertThat(FormulaFunctions.findArgTypeMatch(Arrays.<Class<?>>asList(VNumber.class, VNumber.class), functions).isEmpty(), equalTo(true)); assertThat(FormulaFunctions.findArgTypeMatch(Arrays.<Class<?>>asList(Number.class), functions), contains(function2)); assertThat(FormulaFunctions.findArgTypeMatch(Arrays.<Class<?>>asList(String.class), functions), contains(function1)); }
public static Collection<FormulaFunction> findArgTypeMatch(List<Class<?>> argTypes, Collection<FormulaFunction> formulaFunctions) { Collection<FormulaFunction> functions = new HashSet<>(); for (FormulaFunction formulaFunction : formulaFunctions) { if (formulaFunction.getArgumentTypes().equals(argTypes)) { functions.add(formulaFunction); } } return functions; }
FormulaFunctions { public static Collection<FormulaFunction> findArgTypeMatch(List<Class<?>> argTypes, Collection<FormulaFunction> formulaFunctions) { Collection<FormulaFunction> functions = new HashSet<>(); for (FormulaFunction formulaFunction : formulaFunctions) { if (formulaFunction.getArgumentTypes().equals(argTypes)) { functions.add(formulaFunction); } } return functions; } }
FormulaFunctions { public static Collection<FormulaFunction> findArgTypeMatch(List<Class<?>> argTypes, Collection<FormulaFunction> formulaFunctions) { Collection<FormulaFunction> functions = new HashSet<>(); for (FormulaFunction formulaFunction : formulaFunctions) { if (formulaFunction.getArgumentTypes().equals(argTypes)) { functions.add(formulaFunction); } } return functions; }  }
FormulaFunctions { public static Collection<FormulaFunction> findArgTypeMatch(List<Class<?>> argTypes, Collection<FormulaFunction> formulaFunctions) { Collection<FormulaFunction> functions = new HashSet<>(); for (FormulaFunction formulaFunction : formulaFunctions) { if (formulaFunction.getArgumentTypes().equals(argTypes)) { functions.add(formulaFunction); } } return functions; }  static boolean matchArgumentTypes(List<Object> arguments, FormulaFunction function); static boolean matchArgumentTypes(List<Object> arguments, FormulaFunction function, boolean allowNull); static boolean matchArgumentCount(int nArguments, FormulaFunction function); static FormulaFunction findFirstMatch(List<Object> arguments, Collection<FormulaFunction> formulaFunctions); static Collection<FormulaFunction> findArgTypeMatch(List<Class<?>> argTypes, Collection<FormulaFunction> formulaFunctions); static String formatSignature(FormulaFunction function); static String format(String function, List<String> args); }
FormulaFunctions { public static Collection<FormulaFunction> findArgTypeMatch(List<Class<?>> argTypes, Collection<FormulaFunction> formulaFunctions) { Collection<FormulaFunction> functions = new HashSet<>(); for (FormulaFunction formulaFunction : formulaFunctions) { if (formulaFunction.getArgumentTypes().equals(argTypes)) { functions.add(formulaFunction); } } return functions; }  static boolean matchArgumentTypes(List<Object> arguments, FormulaFunction function); static boolean matchArgumentTypes(List<Object> arguments, FormulaFunction function, boolean allowNull); static boolean matchArgumentCount(int nArguments, FormulaFunction function); static FormulaFunction findFirstMatch(List<Object> arguments, Collection<FormulaFunction> formulaFunctions); static Collection<FormulaFunction> findArgTypeMatch(List<Class<?>> argTypes, Collection<FormulaFunction> formulaFunctions); static String formatSignature(FormulaFunction function); static String format(String function, List<String> args);  }