public class SimpleDomainEventStream extends Object implements DomainEventStream
Constructor and Description |
---|
SimpleDomainEventStream(Collection<? extends DomainEventMessage> events)
Initialize the event stream using the given List of DomainEvent and aggregate identifier.
|
SimpleDomainEventStream(DomainEventMessage... events)
Initialize the event stream using the given
DomainEventMessage s and aggregate identifier. |
Modifier and Type | Method and Description |
---|---|
static DomainEventStream |
emptyStream()
Creates an empty 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.
|
public SimpleDomainEventStream(Collection<? extends DomainEventMessage> events)
events
- the list of domain events to streamIllegalArgumentException
- if the given list is emptypublic SimpleDomainEventStream(DomainEventMessage... events)
DomainEventMessage
s and aggregate identifier. The aggregate
identifier is initialized by reading it from the first event available. Therefore, you must provide at least one
event.events
- the list of domain events to streamIllegalArgumentException
- if no events are suppliedpublic boolean 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 DomainEventStream
true
if the stream contains more events.public 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 DomainEventStream.hasNext()
to confirm the existence of elements after the current pointer.next
in interface DomainEventStream
NoSuchElementException
- when no items exist after the current pointer in the streampublic DomainEventMessage peek()
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
NoSuchElementException
- when no items exist after the current pointer in the streampublic static DomainEventStream emptyStream()
Copyright © 2010-2014. All Rights Reserved.