nextEvent

fun <E : Any> nextEvent(eventType: KClass<E>): DomainEvent<E>

Retrieves the next event and validates its type using KClass.

This method advances the iterator and ensures the next event's body is of the expected type.

Return

the next DomainEvent with the validated type

Parameters

E

the expected type of the event body

eventType

the KClass representing the expected event body type

Throws

if there is no next event or the event type doesn't match


fun <E : Any> nextEvent(eventType: Class<E>): DomainEvent<E>

Retrieves the next event and validates its type using Class.

This method advances the iterator and ensures the next event's body is of the expected type. Java-friendly overload using Class instead of KClass.

Return

the next DomainEvent with the validated type

Parameters

E

the expected type of the event body

eventType

the Class representing the expected event body type

Throws

if there is no next event or the event type doesn't match


inline fun <E : Any> nextEvent(): DomainEvent<E>

Retrieves the next event with reified type validation.

This inline method uses reified generics to automatically infer the event type, providing a convenient way to get typed events without explicit type parameters.

Return

the next DomainEvent with the validated type

Parameters

E

the expected type of the event body (inferred by reification)

Throws

if there is no next event or the event type doesn't match