public void testComposition() { Closure<String> toUpperCase = new Closure<String>(null) { public String doCall(String s) { return s.toUpperCase(); } }; Closure<Boolean> hasCapitalA = new Closure<Boolean>(null) { public Boolean doCall(String s) { return s.contains("A"); } }; Closure<Boolean> hasA = toUpperCase.rightShift(hasCapitalA); assertTrue(every(animals, hasA)); Closure<Boolean> alsoHasA = hasCapitalA.leftShift(toUpperCase); assertTrue(every(animals, alsoHasA)); }