Class LazyCollectionStream<T>

java.lang.Object
java.util.Spliterators.AbstractSpliterator<T>
org.jdrupes.builder.core.LazyCollectionStream<T>
Type Parameters:
T - the element type
All Implemented Interfaces:
Spliterator<T>

A stream of elements whose backing collection is obtained lazily from a supplier when the stream is first consumed.
  • Method Details

    • forEachRemaining

      public void forEachRemaining(Consumer<? super T> action)
    • tryAdvance

      public boolean tryAdvance(Consumer<? super T> action)
    • of

      public static <T> Stream<T> of(Supplier<Collection<T>> supplier)
      Creates a stream backed by a collection supplied lazily by the given supplier. The supplier is invoked only when the stream is first consumed.
      Type Parameters:
      T - the element type
      Parameters:
      supplier - supplies the collection
      Returns:
      the stream