public static <I,O> Iterable<O> castingIterable(Iterable<I> it, Class<O> clazz) {
        return map(it, new Processor<I,O>() {
            @SuppressWarnings("unchecked")
            @Override
            public O process(I input) {
                return (O)input;
            }});
    }
public static < I , O > Iterable < O > castingIterable ( Iterable < I > it , Class < O > clazz ) { return map ( it , new Processor < I , O > ( ) { @ SuppressWarnings ( "unchecked" ) @ Override public O process ( I input ) { return ( O ) input ; } } ) ; }
Allows you to iterate over objects and cast them to the appropriate type on the fly.
@param it iterable of I
@param clazz class to cast to
@param <I> input type
@param <O> output type
@return an iterable that casts elements to the specified class.
@throws ClassCastException if the elements are not castable