commonMain.ru.kontur.mobile.visualfsm.Transition.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of visualfsm-core Show documentation
Show all versions of visualfsm-core Show documentation
VisualFSM - Kotlin Multiplatform library for FSM with visualization and analysis tools
package ru.kontur.mobile.visualfsm
import kotlin.reflect.KClass
/**
* Describes the transition rule between states.
* In generic contains [initial state][fromState] and [destination state][toState].
* Defines [predicate] and [transform] functions
*
* @param fromState a [state][State] that FSM had on [transition][Transition] start
* @param toState a [state][State] FSM would have after the [transition][Transition] completes
*/
abstract class Transition(
open val fromState: KClass,
open val toState: KClass,
) {
/**
* Defines requirements for the [transition][Transition] to perform
*
* @param state current [state][State]
* @return true if the transition should be performed, otherwise false
*/
open fun predicate(state: FROM): Boolean {
return true
}
/**
* Creates a [new state][State]
*
* @param state current [state][State]
* @return new [state][State]
*/
abstract fun transform(state: FROM): TO
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy