State Builder
Builder for an individual StatechartState. Triggers and lifecycle hooks are configured by calling onEntry, onExit, onMessage, onTimeout, onCondition, or onSignal inside the state { } block. Composite states declare substates by nesting more state(...) { ... } calls inside the block and naming one via initial.
Each state may have at most one onTimeout and at most one onCondition; declaring more than one will fail at build time. Multiple onMessage / onSignal / onEntry / onExit are allowed and run in declaration order.
Functions
Declare a final (terminal) substate. Entering it auto-stops the whole statechart and fires its onCompletion. See StatechartBuilder.final.
Run block when this state is entered, before any triggers are installed for the state. For composite states, entry runs the parent's actions first, then descends into the initial substate (whose entry actions then run).
Run block when this state is exited, after the state's triggers have been torn down and before the next state is entered. For composite states, substates exit first (bottom-up).
Handle messages of type T arriving in the owner's mailbox while this state (or any substate) is active. When a message arrives, the runtime walks the active chain leaf-to-root and fires the first matching handler — most-specific wins.
Declare a substate with the given substateName. Multiple substates can be declared; one must be designated as the initial via initial.