nextCommandBody

fun <C : Any> nextCommandBody(commandType: KClass<C>): C

Retrieves the body of the next command and asserts it is of the specified type.

Return

The body of the next command cast to the expected type.

Parameters

C

The expected type of the command body.

commandType

The KClass of the expected command body type.

Throws

If no next command exists or the command type doesn't match.


fun <C : Any> nextCommandBody(commandType: Class<C>): C

Retrieves the body of the next command and asserts it is of the specified type (Java Class version).

This is a convenience overload that accepts a Java Class instance.

Return

The body of the next command cast to the expected type.

Parameters

C

The expected type of the command body.

commandType

The Class of the expected command body type.

Throws

If no next command exists or the command type doesn't match.


inline fun <C : Any> nextCommandBody(): C

Retrieves the body of the next command with reified type checking.

This inline function uses reified generics to automatically infer the command type.

Return

The body of the next command cast to the expected type.

Parameters

C

The expected type of the command body (inferred).

Throws

If no next command exists or the command type doesn't match.