Class TransformedIterator<E,T>
java.lang.Object
org.apache.commons.functor.core.collection.TransformedIterator<E,T>
- Type Parameters:
E- the function argument typeT- the iterator elements type
- All Implemented Interfaces:
Iterator<T>
Iterator that transforms another Iterator by applying a UnaryFunction to each returned element.
- Version:
- $Revision$ $Date$
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTransformedIterator(Iterator<? extends E> iterator, UnaryFunction<? super E, ? extends T> function) Create a new TransformedIterator. -
Method Summary
Modifier and TypeMethodDescriptionbooleaninthashCode()booleanhasNext()static <E> Iterator<?> maybeTransform(Iterator<? extends E> iter, UnaryFunction<? super E, ?> func) Get an Iterator instance that may be transformed.next()voidremove()toString()static <E,T> Iterator <T> transform(Iterator<? extends E> iter, UnaryFunction<? super E, ? extends T> func) Get a Transformed Iterator instance.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
function
The function to apply to each iterator element. -
iterator
The wrapped iterator.
-
-
Constructor Details
-
TransformedIterator
public TransformedIterator(Iterator<? extends E> iterator, UnaryFunction<? super E, ? extends T> function) Create a new TransformedIterator.- Parameters:
iterator- Iterator to decoratefunction- to apply
-
-
Method Details
-
hasNext
public boolean hasNext() -
next
-
remove
public void remove() -
equals
-
hashCode
public int hashCode() -
toString
-
transform
public static <E,T> Iterator<T> transform(Iterator<? extends E> iter, UnaryFunction<? super E, ? extends T> func) Get a Transformed Iterator instance.- Type Parameters:
E- the function argument typeT- the iterator elements type- Parameters:
iter- to decorate, if null result is nullfunc- transforming function, cannot be null- Returns:
- Iterator
-
maybeTransform
public static <E> Iterator<?> maybeTransform(Iterator<? extends E> iter, UnaryFunction<? super E, ?> func) Get an Iterator instance that may be transformed.- Type Parameters:
E- the iterator elements type- Parameters:
iter- to decorate, if null result is nullfunc- transforming function, if null result is iter- Returns:
- Iteratorinvalid input: '<'?>
-