All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.molgenis.data.EntityStream Maven / Gradle / Ivy

There is a newer version: 8.4.5
Show newest version
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 predicate) {
    return stream.filter(predicate);
  }

  @Override
  public  Stream map(Function mapper) {
    return stream.map(mapper);
  }

  @Override
  public IntStream mapToInt(ToIntFunction mapper) {
    return stream.mapToInt(mapper);
  }

  @Override
  public LongStream mapToLong(ToLongFunction mapper) {
    return stream.mapToLong(mapper);
  }

  @Override
  public DoubleStream mapToDouble(ToDoubleFunction mapper) {
    return stream.mapToDouble(mapper);
  }

  @Override
  public  Stream flatMap(Function> mapper) {
    return stream.flatMap(mapper);
  }

  @Override
  public IntStream flatMapToInt(Function mapper) {
    return stream.flatMapToInt(mapper);
  }

  @Override
  public LongStream flatMapToLong(Function mapper) {
    return stream.flatMapToLong(mapper);
  }

  @Override
  public DoubleStream flatMapToDouble(Function mapper) {
    return stream.flatMapToDouble(mapper);
  }

  @Override
  public Stream distinct() {
    return stream.distinct();
  }

  @Override
  public Stream sorted() {
    return stream.sorted();
  }

  @Override
  public Stream sorted(Comparator comparator) {
    return stream.sorted(comparator);
  }

  @SuppressWarnings("squid:S3864") // "Stream.peek" should not be used
  @Override
  public Stream peek(Consumer 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 action) {
    stream.forEach(action);
  }

  @Override
  public void forEachOrdered(Consumer 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 collector) {
    return stream.collect(collector);
  }

  @Override
  public Optional min(Comparator comparator) {
    return stream.min(comparator);
  }

  @Override
  public Optional max(Comparator comparator) {
    return stream.max(comparator);
  }

  @Override
  public long count() {
    return stream.count();
  }

  @Override
  public boolean anyMatch(Predicate predicate) {
    return stream.anyMatch(predicate);
  }

  @Override
  public boolean allMatch(Predicate predicate) {
    return stream.allMatch(predicate);
  }

  @Override
  public boolean noneMatch(Predicate predicate) {
    return stream.noneMatch(predicate);
  }

  @Override
  public Optional findFirst() {
    return stream.findFirst();
  }

  @Override
  public Optional findAny() {
    return stream.findAny();
  }
}