Value

interface Value<ID, V : Value<ID, V, S>, S : State<ID, V, S>>

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)
}

Properties

Link copied to clipboard
abstract val id: ID

Returns a unique identifier for this value.

Link copied to clipboard
abstract val state: S

The current state of this value in the state machine.

Functions

Link copied to clipboard
abstract fun update(newState: S): V

Updates this value to a new state.