net.sf.javagimmicks.collections8.transformer.TransformingSpliterator 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.Spliterator;
import java.util.function.Consumer;
import java.util.function.Function;
import net.sf.javagimmicks.transform8.Transforming;
class TransformingSpliterator implements Transforming, Spliterator
{
protected final Spliterator _internalSpliterator;
private final Function _transformer;
TransformingSpliterator(final Spliterator internalSpliterator, final Function transformer)
{
_internalSpliterator = internalSpliterator;
_transformer = transformer;
}
@Override
public boolean tryAdvance(final Consumer super T> action)
{
return _internalSpliterator.tryAdvance(TransformerUtils.decorate(action, getTransformerFunction()));
}
@Override
public Spliterator trySplit()
{
final Spliterator split = _internalSpliterator.trySplit();
return split != null ? TransformerUtils.decorate(split, getTransformerFunction()) : null;
}
@Override
public long estimateSize()
{
return _internalSpliterator.estimateSize();
}
@Override
public int characteristics()
{
return _internalSpliterator.characteristics();
}
@Override
public Function getTransformerFunction()
{
return _transformer;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy