eu.lucaventuri.fibry.fsm.FsmTemplateActor 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 eu.lucaventuri.fibry.MessageOnlyActor;
import java.util.HashMap;
import java.util.Map;
public class FsmTemplateActor, R, ?>, I> extends FsmTemplate {
public FsmTemplateActor(Map> mapEnums) {
super(mapEnums);
}
public FsmActor newFsmActor(S state) {
return new FsmActor<>(mapStates, state);
}
public FsmActor newFsmActorReplace(S state, A actor) {
return new FsmActor<>(replaceAllActors(actor), state);
}
private Map> replaceAllActors(A actor) {
var newMapStates = new HashMap>();
// Replace State in the map
for (var entry : mapStates.entrySet()) {
newMapStates.put(entry.getKey(), entry.getValue().withActor(actor, true));
}
// Replace State in the lists
for (var entry : newMapStates.entrySet()) {
entry.getValue().replaceListActors(actor, newMapStates);
}
return newMapStates;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy