mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-26 12:08:45 +00:00
fix FSMBuilder
This commit is contained in:
parent
4bda70268b
commit
eb78f21eec
@ -7,12 +7,10 @@ import kotlin.reflect.KClass
|
|||||||
|
|
||||||
class FSMBuilder<T : State>(
|
class FSMBuilder<T : State>(
|
||||||
var statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
var statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||||
val fsmBuilder: (states: List<CheckableHandlerHolder<T, T>>, defaultHandler: StatesHandler<T, T>?) -> StatesMachine<T> = { states, defaultHandler ->
|
val fsmBuilder: (states: List<CheckableHandlerHolder<T, T>>, statesManager: StatesManager<T>) -> StatesMachine<T> = { states, statesManager ->
|
||||||
StatesMachine(
|
StatesMachine(
|
||||||
statesManager,
|
statesManager,
|
||||||
states.let { list ->
|
states
|
||||||
defaultHandler ?.let { list + it.holder { true } } ?: list
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
var defaultStateHandler: StatesHandler<T, T>? = StatesHandler { null }
|
var defaultStateHandler: StatesHandler<T, T>? = StatesHandler { null }
|
||||||
@ -50,7 +48,12 @@ class FSMBuilder<T : State>(
|
|||||||
add(filter, handler)
|
add(filter, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun build() = fsmBuilder(states.toList(), defaultStateHandler)
|
fun build() = fsmBuilder(
|
||||||
|
states.toList().let { list ->
|
||||||
|
defaultStateHandler ?.let { list + it.holder { true } } ?: list
|
||||||
|
},
|
||||||
|
statesManager
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T : State> buildFSM(
|
fun <T : State> buildFSM(
|
||||||
|
Loading…
Reference in New Issue
Block a user