StateMapBuilder

class StateMapBuilder<S, E, C, A, R>(val validStates: Set<S>, val name: String? = null, val parentBuilder: StateMachineBuilder<S, E, C, A, R>)

The build will be created to assist with create the top level or named state maps. All transitions are assigned to a state map.

Author

Corneil du Plessis

Constructors

Link copied to clipboard
constructor(validStates: Set<S>, name: String? = null, parentBuilder: StateMachineBuilder<S, E, C, A, R>)

Properties

Link copied to clipboard
val name: String? = null

The name of the statemap.

Link copied to clipboard

The parent state machine builder

Link copied to clipboard

The set of states the state map supports

Functions

Link copied to clipboard
fun automatic(startState: S, targetState: S, action: SyncStateAction<C, A, R>?)

Creates an automatic transition when currentState is the startState. The transition will change to targetState.

fun automatic(startState: S, targetState: S, guard: StateGuard<C, A>, action: SyncStateAction<C, A, R>?)
Link copied to clipboard
fun automaticPop(startState: S, action: SyncStateAction<C, A, R>?)

Creates a pop transition that will return to orginal state that was pushed after executing the action.

fun automaticPop(startState: S, targetState: S, action: SyncStateAction<C, A, R>?)

Creates a pop transition that will pop the last statemap and then change to the targetState.

fun automaticPop(startState: S, guard: StateGuard<C, A>, action: SyncStateAction<C, A, R>?)

Creates an automatic pop transition with will apply when currentState is startState and the guard expression is true.

fun automaticPop(startState: S, targetState: S, guard: StateGuard<C, A>, action: SyncStateAction<C, A, R>?)

Creates a pop transition that will apply when currentState is startState and guard is true. The transition will change to targetMap/targetState

fun automaticPop(startState: S, targetMap: String, targetState: S, action: SyncStateAction<C, A, R>?)

Creates a pop transition that will apply when currentState is startState. The transition will change to targetMap/targetState

fun automaticPop(startState: S, targetMap: String, targetState: S, guard: StateGuard<C, A>, action: SyncStateAction<C, A, R>?)

Create an automatic pop transition when currentState is startState and when guard is true. The transition will target targetMap and targetState

Link copied to clipboard
fun automaticPush(startState: S, targetMap: String, targetState: S, action: SyncStateAction<C, A, R>?)

Creates an automatic push transition when current state is startState for a targetMap and targetState.

fun automaticPush(startState: S, targetMap: String, targetState: S, guard: StateGuard<C, A>, action: SyncStateAction<C, A, R>?)

Creates an automatic push transition for startState. When the currentState is startState and guard is true the targetMap and targetState will become current after executing the optional action

Link copied to clipboard
fun default(event: E, action: SyncStateAction<C, A, R>?)

This function defines an action to be invoked when no transitions are found for given event.

fun default(currentState: S, action: DefaultStateAction<C, S, E, A, R>)

This function defines an action to be invoked when no transitions are found matching the given state and on.

fun default(event: EventState<E, S>, action: SyncStateAction<C, A, R>?)

This function defines an action to be invoked when no transitions match the event. The currentState will be change to second parameter of the Pair.

Link copied to clipboard
fun defaultAction(action: DefaultStateAction<C, S, E, A, R>)

This function defines an action to be invoked when no action is found matching the current state and event. This will be an internal transition and will not cause a change in state or invoke entry or exit functions.

Link copied to clipboard

This function defines an action to be invoked when no entry action is defined for the current state.

Link copied to clipboard

This function defines an action to be invoked when no exit action is defined for the current state.

Link copied to clipboard
fun entry(currentState: S, action: DefaultEntryExitAction<C, S, A>)

This function defines an action to be invoked when the FSM changes to the provided state

Link copied to clipboard
fun exit(currentState: S, action: DefaultEntryExitAction<C, S, A>)

This function defines an action to be invoke when the FSM changes from the provided state

Link copied to clipboard
fun invariant(message: String, condition: Condition<C>)

This function defines an invariant condition that will hold true before and after all transitions.

Link copied to clipboard
fun popTransition(startState: S, event: E, targetState: S?, targetMap: String?, action: SyncStateAction<C, A, R>?)

Creates a pop transition that applies to the startState on a given event. This will result in a new push transition

fun popTransition(startState: S, event: E, targetState: S?, targetMap: String?, guard: StateGuard<C, A>, action: SyncStateAction<C, A, R>?)

Creates a pop transition that applies to the startState on a given event. This will result in a new push transition if the guard expression is true

Link copied to clipboard
fun pushTransition(startState: S, event: E, targetMap: String, targetState: S, action: SyncStateAction<C, A, R>?)

Creates a push transition for a startState and triggered by event. The transition will change to targetMap and targetState.

fun pushTransition(startState: S, event: E, targetMap: String, targetState: S, guard: StateGuard<C, A>, action: SyncStateAction<C, A, R>?)

Creates a push transition for a startState and triggered by event and guard expression being true. The transition will change to targetMap and targetState.

Link copied to clipboard
fun toMap(afterStateChangeAction: StateChangeAction<C, S>?): StateMapDefinition<S, E, C, A, R>

Creates a StateMapDefinition from the data in this builder

Link copied to clipboard
fun transition(startState: S, event: E, action: SyncStateAction<C, A, R>?)

This function defines a transition that doesn't change the state of the state machine when the currentState is startState and the on is received and after the action was performed. No entry or exit actions performed.

fun transition(startState: S, event: E, targetState: S, action: SyncStateAction<C, A, R>?)

This function defines a transition that will be triggered when the currentState is the same as the startState and on is received. The FSM currentState will change to the targetState after the action was executed. Entry and Exit actions will also be performed.

fun transition(startState: S, event: E, guard: StateGuard<C, A>, action: SyncStateAction<C, A, R>?)

This function defines a transition that doesn't change the state also know as an internal transition. The transition will only occur if the guard expression is met.

fun transition(startState: S, event: E, targetState: S, guard: StateGuard<C, A>, action: SyncStateAction<C, A, R>?)

This function defines a transition from the currentState equal to startState to the targetState when event is received and the guard expression is met. The action is executed after any exit action and before entry actions.