Jaggregate and Java 7 closures

The recent draft proposal to add special syntax for local and anonymous functions in Java 7 has gotten me really excited. If this stuff becomes part of the core language, my Jaggregate library will leap to support these typed functions in lieu of or alongside Jaggregate's current unary and binary functors/predicates. So instead of having to write something like:

Set<Integer> singleDigits = Interval.fromTo( 0, 9 ).toSet();
singleDigits.select( new UnaryPredicate<Integer>() {
    public boolean matches( Integer target ) {
        return target % 2 == 0;
    }
} ).forEachDo( new UnaryFunction<Object>() {
    public Object evaluate( Object target ) {
        System.out.println( target );
        return this;
    }
} );

you could write:

Set<Integer> singleDigits = Interval.fromTo( 0, 9 ).toSet();
singleDigits.select( (int target) : target % 2 == 0 )
    .forEachDo( (Object target) : { System.out.println( target ); return this; } );

Sweet, eh?

Written on August 23, 2006