public interface DomainEventStream extends Iterator<DomainEventMessage<?>>
Modifier and Type | Method and Description |
---|---|
default Stream<? extends DomainEventMessage<?>> |
asStream()
Returns this DomainEventStream as a
Stream of DomainEventMessages. |
static DomainEventStream |
concat(DomainEventStream a,
DomainEventStream b)
Concatenate two DomainEventStreams.
|
static DomainEventStream |
empty()
Create an empty DomainEventStream.
|
default DomainEventStream |
filter(Predicate<? super DomainEventMessage<?>> filter)
Returns a stream that provides the items of this stream that match the given
filter . |
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.
|
static DomainEventStream |
of(DomainEventMessage<?>... events)
Create a new DomainEventStream from the given
events . |
static DomainEventStream |
of(DomainEventMessage<?> event)
Create a new DomainEventStream containing only the given
event . |
static DomainEventStream |
of(List<? extends DomainEventMessage<?>> list)
Create a new DomainEventStream with events obtained from the given
list . |
static DomainEventStream |
of(Stream<? extends DomainEventMessage<?>> stream)
Create a new DomainEventStream with events obtained from the given
stream . |
static DomainEventStream |
of(Stream<? extends DomainEventMessage<?>> stream,
Supplier<Long> sequenceNumberSupplier)
Create a new DomainEventStream with events obtained from the given
stream . |
DomainEventMessage<?> |
peek()
Returns the next events in the stream, if available, without moving the pointer forward.
|
default void |
remove() |
forEachRemaining
static DomainEventStream of(Stream<? extends DomainEventMessage<?>> stream, Supplier<Long> sequenceNumberSupplier)
stream
.stream
- Stream that serves as a source of events in the resulting DomainEventStreamsequenceNumberSupplier
- supplier of the sequence number of the last used upstream event entrystatic DomainEventStream of(Stream<? extends DomainEventMessage<?>> stream)
stream
.stream
- Stream that serves as a source of events in the resulting DomainEventStreamstatic DomainEventStream empty()
static DomainEventStream of(DomainEventMessage<?> event)
event
.event
- The event to add to the resulting DomainEventStreamstatic DomainEventStream of(DomainEventMessage<?>... events)
events
.events
- Events to add to the resulting DomainEventStreamstatic DomainEventStream of(List<? extends DomainEventMessage<?>> list)
list
.list
- list that serves as a source of events in the resulting DomainEventStreamstatic DomainEventStream concat(DomainEventStream a, DomainEventStream b)
a
will be followed by
events from stream b
.a
- The first streamb
- The second stream that will follow the first streamdefault DomainEventStream filter(Predicate<? super DomainEventMessage<?>> filter)
filter
.filter
- The filter to apply to the streamboolean hasNext()
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<?>>
true
if the stream contains more events.DomainEventMessage<?> next()
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 hasNext()
to confirm the existence of elements after the current pointer.next
in interface Iterator<DomainEventMessage<?>>
DomainEventMessage<?> peek()
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 hasNext()
to confirm the existence of elements after the current pointer.Long getLastSequenceNumber()
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
.
default void remove()
remove
in interface Iterator<DomainEventMessage<?>>
default Stream<? extends DomainEventMessage<?>> asStream()
Stream
of DomainEventMessages. Note that the returned Stream will
start at the current position of the DomainEventStream.
Note that iterating over the returned Stream may affect this DomainEventStream and vice versa. It is therefore not recommended to use this DomainEventStream after invoking this method.
Copyright © 2010–2024. All rights reserved.