com.tteky.xenonext.fsm.core.TriggerBehaviour Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xenon-fsm Show documentation
Show all versions of xenon-fsm Show documentation
State machine using Xenon Stateful service
The newest version!
package com.tteky.xenonext.fsm.core;
import com.vmware.xenon.common.Operation;
import java.util.AbstractMap;
import java.util.Map;
import java.util.function.Predicate;
public abstract class TriggerBehaviour {
private final String trigger;
private final Predicate guard;
protected TriggerBehaviour(String trigger, Predicate guard) {
this.trigger = trigger;
this.guard = guard;
}
public String getTrigger() {
return trigger;
}
public boolean isGuardConditionMet() {
return guard.test(trigger);
}
public abstract Map.Entry resultsInTransitionFrom(String source, Operation args);
static TriggerBehaviour newTransitionBehaviour(String trigger, String destination, Predicate guard) {
return new TransitioningTriggerBehaviour(trigger, destination, guard);
}
public static class TransitioningTriggerBehaviour extends TriggerBehaviour {
private final String destination;
private TransitioningTriggerBehaviour(String trigger, String destination, Predicate guard) {
super(trigger, guard);
this.destination = destination;
}
@Override
public Map.Entry resultsInTransitionFrom(String source, Operation args) {
return new AbstractMap.SimpleEntry<>(true, destination);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy