public static < T > Iterable < T > filteringIterable ( final Iterable < ? extends T > iterable , final Predicate < ? super T > predicate ) { Objects . requireNonNull ( iterable , "The iterable is null" ) ; Objects . requireNonNull ( predicate , "The predicate is null" ) ; return new Iterable < T > ( ) { @ Override public Iterator < T > iterator ( ) { return new FilteringIterator < T > ( iterable . iterator ( ) , predicate ) ; } } ; }
Returns an iterable that provides an iterator that only returns the elements provided by the iterator of the given iterable to which the given predicate applies .