org.molgenis.data.EntityStream Maven / Gradle / Ivy
package org.molgenis.data;
import static java.util.Objects.requireNonNull;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Optional;
import java.util.Spliterator;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.BinaryOperator;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.function.ToDoubleFunction;
import java.util.function.ToIntFunction;
import java.util.function.ToLongFunction;
import java.util.stream.Collector;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import java.util.stream.Stream;
/** Entity {@link java.util.stream.Stream Stream} */
public class EntityStream implements Stream {
private final Stream stream;
private final boolean isLazy;
public EntityStream(Stream stream, boolean isLazy) {
this.stream = requireNonNull(stream);
this.isLazy = requireNonNull(isLazy);
}
/**
* Returns whether this entity collection is lazy, i.e. all entities are references to entities (=
* lazy entities)
*
* @return whether this entity collection is lazy
*/
public boolean isLazy() {
return isLazy;
}
// delegate methods to decorated stream
@Override
public Iterator iterator() {
return stream.iterator();
}
@Override
public Spliterator spliterator() {
return stream.spliterator();
}
@Override
public boolean isParallel() {
return stream.isParallel();
}
@Override
public Stream sequential() {
return stream.sequential();
}
@Override
public Stream parallel() {
return stream.parallel();
}
@Override
public Stream unordered() {
return stream.unordered();
}
@Override
public Stream onClose(Runnable closeHandler) {
return stream.onClose(closeHandler);
}
@Override
public void close() {
stream.close();
}
@Override
public Stream filter(Predicate super Entity> predicate) {
return stream.filter(predicate);
}
@Override
public Stream map(Function super Entity, ? extends R> mapper) {
return stream.map(mapper);
}
@Override
public IntStream mapToInt(ToIntFunction super Entity> mapper) {
return stream.mapToInt(mapper);
}
@Override
public LongStream mapToLong(ToLongFunction super Entity> mapper) {
return stream.mapToLong(mapper);
}
@Override
public DoubleStream mapToDouble(ToDoubleFunction super Entity> mapper) {
return stream.mapToDouble(mapper);
}
@Override
public Stream flatMap(Function super Entity, ? extends Stream extends R>> mapper) {
return stream.flatMap(mapper);
}
@Override
public IntStream flatMapToInt(Function super Entity, ? extends IntStream> mapper) {
return stream.flatMapToInt(mapper);
}
@Override
public LongStream flatMapToLong(Function super Entity, ? extends LongStream> mapper) {
return stream.flatMapToLong(mapper);
}
@Override
public DoubleStream flatMapToDouble(Function super Entity, ? extends DoubleStream> mapper) {
return stream.flatMapToDouble(mapper);
}
@Override
public Stream distinct() {
return stream.distinct();
}
@Override
public Stream sorted() {
return stream.sorted();
}
@Override
public Stream sorted(Comparator super Entity> comparator) {
return stream.sorted(comparator);
}
@SuppressWarnings("squid:S3864") // "Stream.peek" should not be used
@Override
public Stream peek(Consumer super Entity> action) {
return stream.peek(action);
}
@Override
public Stream limit(long maxSize) {
return stream.limit(maxSize);
}
@Override
public Stream skip(long n) {
return stream.skip(n);
}
@Override
public void forEach(Consumer super Entity> action) {
stream.forEach(action);
}
@Override
public void forEachOrdered(Consumer super Entity> action) {
stream.forEachOrdered(action);
}
@Override
public Object[] toArray() {
return stream.toArray();
}
@Override
public A[] toArray(IntFunction generator) {
return stream.toArray(generator);
}
@Override
public Entity reduce(Entity identity, BinaryOperator accumulator) {
return stream.reduce(identity, accumulator);
}
@Override
public Optional reduce(BinaryOperator accumulator) {
return stream.reduce(accumulator);
}
@Override
public U reduce(
U identity, BiFunction accumulator, BinaryOperator combiner) {
return stream.reduce(identity, accumulator, combiner);
}
@Override
public R collect(
Supplier supplier, BiConsumer accumulator, BiConsumer combiner) {
return stream.collect(supplier, accumulator, combiner);
}
@Override
public R collect(Collector super Entity, A, R> collector) {
return stream.collect(collector);
}
@Override
public Optional min(Comparator super Entity> comparator) {
return stream.min(comparator);
}
@Override
public Optional max(Comparator super Entity> comparator) {
return stream.max(comparator);
}
@Override
public long count() {
return stream.count();
}
@Override
public boolean anyMatch(Predicate super Entity> predicate) {
return stream.anyMatch(predicate);
}
@Override
public boolean allMatch(Predicate super Entity> predicate) {
return stream.allMatch(predicate);
}
@Override
public boolean noneMatch(Predicate super Entity> predicate) {
return stream.noneMatch(predicate);
}
@Override
public Optional findFirst() {
return stream.findFirst();
}
@Override
public Optional findAny() {
return stream.findAny();
}
}