Value
Represents a value that can transition between different states in a finite state machine.
This interface defines the core behavior for values that can be managed by a state machine. It provides methods to track the current state and update to a new state.
Parameters
V
The concrete type of the value implementing this interface
S
The type of state that this value can transition between
See also
Example usage:
enum class Color { RED, YELLOW, GREEN }
data class Light(override val state: Color, override val id: String) : Value<String, Light, Color> {
override fun update(newState: Color): Light = copy(state = newState)
}
Content copied to clipboard