nextEventBody

fun <E : Any> nextEventBody(eventType: KClass<E>): E

Retrieves the body of the next event and validates its type using KClass.

This method advances the iterator and returns only the event body, ensuring it is of the expected type.

Return

the body of the next event 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> nextEventBody(eventType: Class<E>): E

Retrieves the body of the next event and validates its type using Class.

This method advances the iterator and returns only the event body, ensuring it is of the expected type. Java-friendly overload using Class instead of KClass.

Return

the body of the next event 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> nextEventBody(): E

Retrieves the body of 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 event bodies without explicit type parameters.

Return

the body of the next event 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