Repository navigation
5.4.2.2.4. Final State
Final State represents stable configuration of State Machine. There can be exactly one Final State per Region (if Final State is a substate of Composite State or Orthogonal State) or exactly one per State Machine (if Final State is defined on State Machine's main level).
Final State can't have any outgoing Transitions and, when reached, cannot be exited explicitly. It can be exited only implicitly when parent State is exited.
Final State can't define any OnEntry / OnExit logic.
Outcome of reaching Final State differs depending on its owner:
- Composite States and Orthogonal States are finalized when Final States in all their Regions are reached,
- State Machine Behavior is finalized when Final State that is a direct child of a State Machine is reached.
Final State consist of:
- Name, uniquely identifying Final State within State Machine,
- Parent State, if Final State is a substate of Composite State or Orthogonal State.
In UML, Final State is represented by double circle:
stateDiagram-v2
InitialState --> [*] : Finish
Equivalent Stateflows notation of States:
Definition fragment (inside the builder callback):
/* fragment of State Machine definition */
.AddState("InitialState", b => b
.AddTransition<Finish>("final")
)
.AddFinalState("final")If there is just one Final State in State Machine, shortened notation with default name can be used:
Definition fragment (inside the builder callback):
/* fragment of State Machine definition */
.AddState("InitialState", b => b
.AddTransition<Finish>(FinalState.Name)
)
.AddFinalState() // no name provided here, default name usedUsing lambda style here means that Final State is referred to by string name.
public class InitialState : IState
{ }Definition fragment (inside the builder callback):
/* fragment of State Machine definition */
.AddState<InitialState>(b => b
.AddTransition<Finish, FinalState>()
)
.AddFinalState()Using typed style here means that Final State is represented by a class, in the example predefined
FinalStateclass is used.
FinalState class can be used as a target for typed style Transitions if State Machine contains just one Final State. If there are more Final States, there is an important concern of State identity to be considered.
Home page Support Code licensed under an MIT-style License. Documentation licensed under CC BY 4.0. © by Mikołaj Milewski, 2026