Skip to content

Instantly share code, notes, and snippets.

@ddeaguiar
Created April 7, 2009 13:24
Show Gist options
  • Save ddeaguiar/91233 to your computer and use it in GitHub Desktop.
Save ddeaguiar/91233 to your computer and use it in GitHub Desktop.
public void testInject() {
List ints = Arrays.asList(new Integer[]{new Integer(1), new Integer(2), new Integer(3)});
SumAccumulator acc = new SumAccumulator();
CollectionUtils.forAllDo(ints, acc);
assertEquals(6, acc.result);
}
static class SumAccumulator implements Closure {
public int result;
public void execute(Object arg0) {
result += ((Integer) arg0).intValue();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment