package org.eclipse.collections.impl.lazy.parallel.bag;
import org.eclipse.collections.api.annotation.Beta;
import org.eclipse.collections.api.block.function.Function;
import org.eclipse.collections.api.block.predicate.Predicate;
import org.eclipse.collections.api.block.procedure.Procedure;
import org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure;
import org.eclipse.collections.impl.block.factory.Functions;
import org.eclipse.collections.impl.lazy.parallel.AbstractBatch;
import org.eclipse.collections.impl.lazy.parallel.Batch;
@Beta
public class CollectUnsortedBagBatch<T, V> extends AbstractBatch<V> implements UnsortedBagBatch<V>
{
private final Batch<T> unsortedBagBatch;
private final Function<? super T, ? extends V> function;
public CollectUnsortedBagBatch(Batch<T> unsortedBagBatch, Function<? super T, ? extends V> function)
{
this.unsortedBagBatch = unsortedBagBatch;
this.function = function;
}
@Override
public void forEach(Procedure<? super V> procedure)
{
this.unsortedBagBatch.forEach(Functions.bind(procedure, this.function));
}
@Override
public void forEachWithOccurrences(ObjectIntProcedure<? super V> procedure)
{
throw new UnsupportedOperationException("not implemented yet");
}
@Override
public UnsortedBagBatch<V> select(Predicate<? super V> predicate)
{
return new SelectUnsortedBagBatch<>(this, predicate);
}
@Override
public <VV> UnsortedBagBatch<VV> collect(Function<? super V, ? extends VV> function)
{
return new CollectUnsortedBagBatch<>(this, function);
}
@Override
public <V1> UnsortedBagBatch<V1> flatCollect(Function<? super V, ? extends Iterable<V1>> function)
{
return new FlatCollectUnsortedBagBatch<>(this, function);
}
}