It is relatively easy to adapt a closure to a one-method interface. And such conversion should be very useful for implementing functors from within groovy.
syntax can be:
{a->a.name=="a"} as Predicate
The attached class is a dynamic proxy that implements this adapter functionality. It is currently used in a category class to enable a syntax like "Predicate.impl {...}".
Just hook it up to the "as" keyword should make it work.
Description
It is relatively easy to adapt a closure to a one-method interface. And such conversion should be very useful for implementing functors from within groovy.
syntax can be:
{a->a.name=="a"} as Predicate
The attached class is a dynamic proxy that implements this adapter functionality. It is currently used in a category class to enable a syntax like "Predicate.impl {...}".
Just hook it up to the "as" keyword should make it work.
I applied a modified version of the patch and added a test