com.alibaba.cola.statemachine.Transition Maven / Gradle / Ivy
package com.alibaba.cola.statemachine;
import com.alibaba.cola.statemachine.impl.TransitionType;
/**
* {@code Transition} is something what a state machine associates with a state
* changes.
*
* @author Frank Zhang
*
* @param the type of state
* @param the type of event
* @param the type of user defined context, which is used to hold application data
*
* @date 2020-02-07 2:20 PM
*/
public interface Transition{
/**
* Gets the source state of this transition.
*
* @return the source state
*/
State getSource();
void setSource(State state);
E getEvent();
void setEvent(E event);
void setType(TransitionType type);
/**
* Gets the target state of this transition.
*
* @return the target state
*/
State getTarget();
void setTarget(State state);
/**
* Gets the guard of this transition.
*
* @return the guard
*/
Condition getCondition();
void setCondition(Condition condition);
Action getAction();
void setAction(Action action);
/**
* Do transition from source state to target state.
*
* @return the target state
*/
State transit(C ctx);
/**
* Verify transition correctness
*/
void verify();
}