FormatFunction implements Function<String> { @Override public String apply(List<Object> objects) { Object[] formatArgs = objects.subList(1, objects.size()).toArray(); return String.format(String.valueOf(objects.get(0)), formatArgs); }  @Override Set<String> validateInput(List<Object> args); @Override Class<String> getReturnType(); @Override FunctionName getName(); @Override String apply(List<Object> objects); @Override String getSignature(); @Override String getDescription();  }
@Test public void apply() throws Exception { assertThat(function.apply(Collections.singletonList("a string")), equalTo("a string")); assertThat(function.apply(Arrays.asList("number: %.2f", -1.5)), equalTo("number: -1.50")); }
@Test(expected = IllegalFormatException.class) public void illegalFormat() throws Exception { function.apply(Arrays.asList("%d", "string")); }