Making a Java library "Groovy"
groovy
Solution
The only method you need to provide is the `iterator()` method. You then get all of the Groovy Object iteration methods (`each()`, `find()`, `any()`, `every()`, `collect()`, ...) for free!
Problem
I fell in love with Groovy and try to use it more and more. Now I have to work with Oracle Forms Jdapi library. When working with this library, you write a lot of code like this: ``` JdapiIterator progIterator = getWorkForm().getProgramUnits(); while(progIterator.hasNext()) { ProgramUnit currProgUnit = (ProgramUnit) progIterator.next(); ... } ``` and of cource I would like to write ``` getWorkForm().programUnits.each { ... } ``` However, I never wrote a Groovy interface to an existing Java library and need some assistance. I know about Groovy 2.0's extension methods, but in that case I am thinking about a class with the same name in a different namespace which delegates only to the functions I would like to keep. What is the best approach for providing the `each` functionality, but also all other closures applicable for collections? I would appreciate if you point me in the right direction!