Class StreamSpliterator<T>

java.lang.Object
java.util.Spliterators.AbstractSpliterator<T>
org.axonframework.eventsourcing.eventstore.StreamSpliterator<T>
Type Parameters:
T - The generic type serves by this Spliterators.AbstractSpliterator implementation.
All Implemented Interfaces:
Spliterator<T>

@Internal public class StreamSpliterator<T> extends Spliterators.AbstractSpliterator<T>
An Spliterators.AbstractSpliterator implementation used internally to feed a Stream through the StreamSupport.stream(Spliterator, boolean) operation.
Since:
3.0.0
Author:
Rene de Waele
  • Constructor Details

    • StreamSpliterator

      public StreamSpliterator(@Nonnull Function<T,List<? extends T>> fetchFunction, @Nonnull Predicate<List<? extends T>> finalFetchPredicate)
      Constructs a StreamSpliterator using the given fetchFunction and finalFetchPredicate.

      Both lambdas are used in the tryAdvance(Consumer) operation of this spliterator. The fetchFunction retrieves collections of type T, which are fed to the action of tryAdvance(Consumer).

      The finalFetchPredicate signals when the fetchFunction has done its last fetch operation. Whenever this Predicate returns true, tryAdvance(Consumer) will return false, to signal the stream is done.

      Parameters:
      fetchFunction - Lambda used to fetch new entries of type T to iteratively provide to the action of tryAdvance(Consumer).
      finalFetchPredicate - Lambda dictating when the fetchFunction has done its last fetch.
  • Method Details

    • tryAdvance

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