eu.lucaventuri.fibry.fsm.FsmConsumer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fibry Show documentation
Show all versions of fibry Show documentation
The first Java Actor System supporting fibers from Project Loom
package eu.lucaventuri.fibry.fsm;
import java.util.Map;
import java.util.function.Consumer;
public class FsmConsumer>, I> extends FsmBase {
FsmConsumer(Map> mapStates, S currentState) {
super(mapStates, currentState);
}
public S onEvent(M event, I userData) {
return onEvent(event, userData, true, true);
}
public S onEvent(M event, I userData, boolean notifyConsumer, boolean exceptionOnUnexpectedEvent) {
var prevState = mapStates.get(currentState);
var nextState = prevState.onEvent(event, exceptionOnUnexpectedEvent);
currentState = nextState.state;
if (notifyConsumer && nextState.actor != null)
nextState.actor.accept(new FsmContext<>(prevState.state, nextState.state, event, userData));
return nextState.state;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy