public static < T , U > Collection < T > findResults ( Iterator < U > self , @ ClosureParams ( FirstParam . FirstGenericType . class ) Closure < T > filteringTransform ) { List < T > result = new ArrayList < T > ( ) ; while ( self . hasNext ( ) ) { U value = self . next ( ) ; T transformed = filteringTransform . call ( value ) ; if ( transformed != null ) { result . add ( transformed ) ; } } return result ; }
Iterates through the Iterator transforming items using the supplied closure and collecting any non - null results .