FoldFn implements Accumulation<INPUT, OUTPUT, OUTPUT> { public FoldFn() { } FoldFn();  FoldFn(OUTPUT initialVal); @Override OUTPUT defaultAccumulatedValue(); @Override OUTPUT accumulate(OUTPUT accumulatedValue, INPUT input); @Override OUTPUT getOutput(OUTPUT accumulatedValue); @Override OUTPUT getRetraction(OUTPUT value);  }
@Test public void FoldFnTest() { FoldFn<String, String> concat = new FoldFn<String, String>() { @Override public String merge(String accumulatedValue1, String accumulatedValue2) { return fold(accumulatedValue1, accumulatedValue2); } @Override public String fold(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); }