io.github.yangziwen.quickstate.builder.StateMachineBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quick-state Show documentation
Show all versions of quick-state Show documentation
A lightweight state machine
package io.github.yangziwen.quickstate.builder;
import java.util.Map;
import io.github.yangziwen.quickstate.State;
import io.github.yangziwen.quickstate.StateMachine;
import io.github.yangziwen.quickstate.StateMachineFactory;
import io.github.yangziwen.quickstate.TransitionType;
import io.github.yangziwen.quickstate.impl.TransitionBuilderImpl;
public interface StateMachineBuilder> {
default ExternalTransitionBuilder externalTransition() {
return new TransitionBuilderImpl<>(getStateMap(), TransitionType.EXTERNAL);
}
default InternalTransitionBuilder internalTransition() {
return new TransitionBuilderImpl<>(getStateMap(), TransitionType.INTERNAL);
}
default M build(String machineId) {
M stateMachine = newStateMachine(machineId, getStateMap());
StateMachineFactory.register(stateMachine);
return stateMachine;
}
M newStateMachine(String machineId, Map> stateMap);
Map> getStateMap();
}