@Test(expected = RuntimeException.class) public void testThrowsWhenCalledWithInvalidNumberOfArguments() { final JoinFunction joinFunction = new JoinFunction(); joinFunction.call(","); joinFunction.call(",", generateTestData(), new Object()); }
@Override public Object call(Object... args) { if (args.length != 2) { throw new RuntimeException(String.format("Invalid number of arguments (%s) supplied to a join function", args.length)); } else if (args[0].getClass() != String.class) { throw new RuntimeException(String.format("%s: Is not a valid first argument to join. It should be a string delimiter", args[0].getClass())); } else if (args[1].getClass() != StringArrayInput.class) { throw new RuntimeException(String.format("%s: Is not a valid second argument to join. It should be a list of strings", args[1].getClass())); } else { final String separator = (String)args[0]; final StringArrayInput entries = (StringArrayInput) args[1]; return String.join(separator, entries.getValues()); } }
JoinFunction implements FreeFunction { @Override public Object call(Object... args) { if (args.length != 2) { throw new RuntimeException(String.format("Invalid number of arguments (%s) supplied to a join function", args.length)); } else if (args[0].getClass() != String.class) { throw new RuntimeException(String.format("%s: Is not a valid first argument to join. It should be a string delimiter", args[0].getClass())); } else if (args[1].getClass() != StringArrayInput.class) { throw new RuntimeException(String.format("%s: Is not a valid second argument to join. It should be a list of strings", args[1].getClass())); } else { final String separator = (String)args[0]; final StringArrayInput entries = (StringArrayInput) args[1]; return String.join(separator, entries.getValues()); } } }
JoinFunction implements FreeFunction { @Override public Object call(Object... args) { if (args.length != 2) { throw new RuntimeException(String.format("Invalid number of arguments (%s) supplied to a join function", args.length)); } else if (args[0].getClass() != String.class) { throw new RuntimeException(String.format("%s: Is not a valid first argument to join. It should be a string delimiter", args[0].getClass())); } else if (args[1].getClass() != StringArrayInput.class) { throw new RuntimeException(String.format("%s: Is not a valid second argument to join. It should be a list of strings", args[1].getClass())); } else { final String separator = (String)args[0]; final StringArrayInput entries = (StringArrayInput) args[1]; return String.join(separator, entries.getValues()); } }  }
JoinFunction implements FreeFunction { @Override public Object call(Object... args) { if (args.length != 2) { throw new RuntimeException(String.format("Invalid number of arguments (%s) supplied to a join function", args.length)); } else if (args[0].getClass() != String.class) { throw new RuntimeException(String.format("%s: Is not a valid first argument to join. It should be a string delimiter", args[0].getClass())); } else if (args[1].getClass() != StringArrayInput.class) { throw new RuntimeException(String.format("%s: Is not a valid second argument to join. It should be a list of strings", args[1].getClass())); } else { final String separator = (String)args[0]; final StringArrayInput entries = (StringArrayInput) args[1]; return String.join(separator, entries.getValues()); } }  @Override Object call(Object... args); }
JoinFunction implements FreeFunction { @Override public Object call(Object... args) { if (args.length != 2) { throw new RuntimeException(String.format("Invalid number of arguments (%s) supplied to a join function", args.length)); } else if (args[0].getClass() != String.class) { throw new RuntimeException(String.format("%s: Is not a valid first argument to join. It should be a string delimiter", args[0].getClass())); } else if (args[1].getClass() != StringArrayInput.class) { throw new RuntimeException(String.format("%s: Is not a valid second argument to join. It should be a list of strings", args[1].getClass())); } else { final String separator = (String)args[0]; final StringArrayInput entries = (StringArrayInput) args[1]; return String.join(separator, entries.getValues()); } }  @Override Object call(Object... args);  }