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>
-
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 interface Iterator
forEachRemaining
-
Field Details
-
function
The function to apply to each iterator element. -
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
-
next
-
remove
-
equals
-
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: '<'?>
-