ReduceFn implements Accumulation<INPUT, INPUT, INPUT> { @Override public INPUT accumulate(INPUT accumulatedValue, INPUT input) { if (accumulatedValue == null) { return input; } return reduce(accumulatedValue, input); }  @Override INPUT defaultAccumulatedValue(); @Override INPUT accumulate(INPUT accumulatedValue, INPUT input); @Override INPUT merge(INPUT accumulatedValue1, INPUT accumulatedValue2); @Override INPUT getOutput(INPUT accumulatedValue); @Override INPUT getRetraction(INPUT value); abstract INPUT reduce(INPUT input1, INPUT input2);  }
@Test public void ReduceFnTest() { ReduceFn<String> concat = new ReduceFn<String>() { @Override public String reduce(String input1, String input2) { return input1 + ", " + input2; } }; String[] ss = new String[]{"b", "c", "d", "e"}; String base = "a"; for (String s : ss) { base = concat.accumulate(base, s); } Assert.assertEquals("a, b, c, d, e", base); }