Class IteratorBackedDomainEventStream

java.lang.Object
org.axonframework.eventsourcing.eventstore.IteratorBackedDomainEventStream
All Implemented Interfaces:
Iterator<DomainEventMessage<?>>, DomainEventStream

public class IteratorBackedDomainEventStream extends Object implements DomainEventStream
DomainEventStream implementation that gets its messages from an Iterator.
Since:
3.0.3
  • Constructor Details

    • IteratorBackedDomainEventStream

      public IteratorBackedDomainEventStream(Iterator<? extends DomainEventMessage<?>> iterator)
      Initialize the stream which provides access to message from the given iterator
      Parameters:
      iterator - The iterator providing the messages to stream
  • Method Details

    • peek

      public DomainEventMessage<?> peek()
      Description copied from interface: DomainEventStream
      Returns the next events in the stream, if available, without moving the pointer forward. Hence, a call to DomainEventStream.next() will return the same event as a call to peek(). Use hasNext() to obtain a guarantee about the availability of any next event.

      If the pointer has reached the end of the stream, the behavior of this method is undefined. It could either return null, or throw an exception, depending on the actual implementation. Use DomainEventStream.hasNext() to confirm the existence of elements after the current pointer.

      Specified by:
      peek in interface DomainEventStream
      Returns:
      the next event in the stream.
    • hasNext

      public boolean hasNext()
      Description copied from interface: DomainEventStream
      Returns true if the stream has more events, meaning that a call to next() will not result in an exception. If a call to this method returns false, there is no guarantee about the result of a consecutive call to next()
      Specified by:
      hasNext in interface DomainEventStream
      Specified by:
      hasNext in interface Iterator<DomainEventMessage<?>>
      Returns:
      true if the stream contains more events.
    • next

      public DomainEventMessage<?> next()
      Description copied from interface: DomainEventStream
      Returns the next events in the stream, if available. Use hasNext() to obtain a guarantee about the availability of any next event. Each call to next() will forward the pointer to the next event in the stream.

      If the pointer has reached the end of the stream, the behavior of this method is undefined. It could either return null, or throw an exception, depending on the actual implementation. Use DomainEventStream.hasNext() to confirm the existence of elements after the current pointer.

      Specified by:
      next in interface DomainEventStream
      Specified by:
      next in interface Iterator<DomainEventMessage<?>>
      Returns:
      the next event in the stream.
    • getLastSequenceNumber

      public Long getLastSequenceNumber()
      Description copied from interface: DomainEventStream
      Get the highest known sequence number in the upstream event entry stream. Note that, as result of upcasting it is possible that the last event in this stream has a lower sequence number than that returned by this method.

      To get the highest absolute sequence number of the underlying event entry stream make sure to iterate over all elements in the stream before calling this method.

      If the stream is empty this method returns null.

      Specified by:
      getLastSequenceNumber in interface DomainEventStream
      Returns:
      the sequence number of the last known upstream event entry