Created
April 7, 2009 13:24
-
-
Save ddeaguiar/91233 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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