net.sf.javagimmicks.collections8.transformer.TransformingIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gimmicks Show documentation
Show all versions of gimmicks Show documentation
Utility classes, APIs and tools for Java
package net.sf.javagimmicks.collections8.transformer;
import java.util.Iterator;
import java.util.function.Function;
import net.sf.javagimmicks.transform8.Transforming;
class TransformingIterator implements Iterator, Transforming
{
protected final Iterator _internalIterator;
private final Function _transformer;
TransformingIterator(Iterator iterator, Function transformer)
{
_internalIterator = iterator;
_transformer = transformer;
}
public Function getTransformerFunction()
{
return _transformer;
}
public boolean hasNext()
{
return _internalIterator.hasNext();
}
public T next()
{
return transform(_internalIterator.next());
}
public void remove()
{
_internalIterator.remove();
}
protected T transform(F element)
{
return getTransformerFunction().apply(element);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy