net.sf.javagimmicks.collections.transformer.TransformingIterator Maven / Gradle / Ivy
package net.sf.javagimmicks.collections.transformer;
import java.util.Iterator;
import net.sf.javagimmicks.transform.Transforming;
import net.sf.javagimmicks.util.Function;
class TransformingIterator implements Iterator, Transforming
{
protected final Iterator _internalIterator;
private final Function _transformer;
/**
* @deprecated Use TranformerUtils.decorate() instead
*/
@Deprecated
public 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