EventIterator
class EventIterator(val delegate: Iterator<DomainEvent<*>>) : Iterator<DomainEvent<*>> , Decorator<Iterator<DomainEvent<*>>>
A decorator for iterating over domain events with convenient access methods.
This class provides type-safe methods for traversing domain event streams, allowing easy access to event bodies and skipping events during testing.
Example usage:
val eventIterator = EventIterator(domainEventStream.iterator())
// Skip the first event
eventIterator.skip(1)
// Get the next event as a specific type
val orderCreated = eventIterator.nextEventBody<OrderCreated>()
// Get the full event with metadata
val paymentEvent = eventIterator.nextEvent<OrderPaid>()Content copied to clipboard
Parameters
delegate
the underlying iterator to decorate
Functions
Link copied to clipboard
Link copied to clipboard
Retrieves the next event with reified type validation.
Retrieves the next event and validates its type using Class.
Retrieves the next event and validates its type using KClass.
Link copied to clipboard
Retrieves the body of the next event with reified type validation.
Retrieves the body of the next event and validates its type using Class.
Retrieves the body of the next event and validates its type using KClass.
Link copied to clipboard
Skips a specified number of events in the iterator.