public static < F , T > Iterable < T > map ( final Iterable < F > fromIterable , final Function < ? super F , ? extends T > function ) { checkNotNull ( fromIterable , "iterable must be non null" ) ; checkNotNull ( function , "map function must be non null" ) ; return new Iterable < T > ( ) { @ Override public Iterator < T > iterator ( ) { final Iterator < F > fromIterator = fromIterable . iterator ( ) ; return new ImmutableIterator < T > ( ) { @ Override public boolean hasNext ( ) { return fromIterator . hasNext ( ) ; } @ Override public T next ( ) { return function . apply ( fromIterator . next ( ) ) ; } } ; } } ; }
Create an iterable that maps an existing iterable to a new one by applying a function to each of it s elements .