public class IteratorBackedDomainEventStream extends Object implements DomainEventStream
Constructor and Description |
---|
IteratorBackedDomainEventStream(Iterator<? extends DomainEventMessage<?>> iterator)
Initialize the stream which provides access to message from the given
iterator |
Modifier and Type | Method and Description |
---|---|
Long |
getLastSequenceNumber()
Get the highest known sequence number in the upstream event entry stream.
|
boolean |
hasNext()
Returns
true if the stream has more events, meaning that a call to next() will not
result in an exception. |
DomainEventMessage<?> |
next()
Returns the next events in the stream, if available.
|
DomainEventMessage<?> |
peek()
Returns the next events in the stream, if available, without moving the pointer forward.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
asStream, concat, empty, filter, of, of, of, of, of, remove
forEachRemaining
public IteratorBackedDomainEventStream(Iterator<? extends DomainEventMessage<?>> iterator)
iterator
iterator
- The iterator providing the messages to streampublic DomainEventMessage<?> peek()
DomainEventStream
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.peek
in interface DomainEventStream
public boolean hasNext()
DomainEventStream
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()
hasNext
in interface Iterator<DomainEventMessage<?>>
hasNext
in interface DomainEventStream
true
if the stream contains more events.public DomainEventMessage<?> next()
DomainEventStream
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.next
in interface Iterator<DomainEventMessage<?>>
next
in interface DomainEventStream
public Long getLastSequenceNumber()
DomainEventStream
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
.
getLastSequenceNumber
in interface DomainEventStream
Copyright © 2010–2024. All rights reserved.