StateCallback

fun interface StateCallback<T, in R, U>

A callback for manipulating and invoking side effects with state information.

When expectations output some state in some way (e.g., an expect(SomeNode) that emits an instance of SomeNode), said state can be transformed and/or stored using a state callback. State callbacks take in a mutable storage and a state, and returns some state. Implementations can return state directly or transform it and return it in some way.

Parameters

T

The context type (see NodeParameterKey for details)

R

The initial type of the state, as input into this callback

U

The returned, possibly transformed type of the state. May be the same as R.

Inheritors

Functions

Link copied to clipboard
fun <T, R> StateCallback<T, R, *>?.createStoreMap(value: R): Map<NodeParameterKey<T, *>, Any?>

Create a store map and evaluate this state callback. The map is returned.

Link copied to clipboard
abstract fun reduceState(storage: MutableMap<NodeParameterKey<T, *>, Any?>, state: R): U

Reduce the provided state, optionally storing it in the storage.

Link copied to clipboard
fun <T, R> StateCallback<T, R, *>?.withStoreMap(value: R, currIndex: Int, handler: (Map<NodeParameterKey<T, *>, Any?>) -> ExpectationResult<T>): ExpectationResult<T>

Create a store map (using createStoreMap) and call the provided handler, returning an ExpectationResult.