Class ActivationLifeCycle
- java.lang.Object
-
- org.eclipse.viatra.transformation.evm.api.ActivationLifeCycle
-
- Direct Known Subclasses:
UnmodifiableActivationLifeCycle
public class ActivationLifeCycle extends java.lang.Object
A life cycle describes how the state of an activation changes in response to an event. The internal representation is a state machine with each transition labeled with an activation life-cycle event.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ActivationLifeCycle.Transition
-
Constructor Summary
Constructors Modifier Constructor Description protected
ActivationLifeCycle(ActivationState inactiveState)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addStateTransition(ActivationLifeCycle.Transition transition)
Extends the life cycle with a new transition that is created from the given state, labeled with the given event and leading to the given state.boolean
addStateTransition(ActivationState from, EventType event, ActivationState to)
Extends the life cycle with a new transition that is created from the given state, labeled with the given event and leading to the given state.boolean
containsFrom(ActivationState state)
Check that the life-cycle contains a transition from the given state.boolean
containsTo(ActivationState state)
Check that the life-cycle contains a transition to the given state.static ActivationLifeCycle
copyOf(ActivationLifeCycle lifeCycle)
Creates a complete copy of the life-cyclestatic ActivationLifeCycle
create(ActivationState inactiveState)
ActivationState
getInactiveState()
java.util.Set<ActivationLifeCycle.Transition>
getStateTransitions()
Returns a copy of the transition table.ActivationState
nextActivationState(ActivationState currentState, EventType event)
Returns the state in the life cycle that is defined as the next state from the given current state in response to the given event.java.lang.String
toString()
-
-
-
Constructor Detail
-
ActivationLifeCycle
protected ActivationLifeCycle(ActivationState inactiveState)
-
-
Method Detail
-
nextActivationState
public ActivationState nextActivationState(ActivationState currentState, EventType event)
Returns the state in the life cycle that is defined as the next state from the given current state in response to the given event. If there is no transition for the given event, the method returns null.- Parameters:
currentState
- the current state of the activationevent
- the event that causes the state transition- Returns:
- the next state if defined, null otherwise
-
addStateTransition
public boolean addStateTransition(ActivationState from, EventType event, ActivationState to)
Extends the life cycle with a new transition that is created from the given state, labeled with the given event and leading to the given state. If the (from,event) transition already exists in the life-cycle, it is overwritten with the given to state.- Parameters:
from
- the source state of the transitionevent
- the event causing the transitionto
- the target state of the transition- Returns:
- true, if the life-cycle changed
-
addStateTransition
public boolean addStateTransition(ActivationLifeCycle.Transition transition)
Extends the life cycle with a new transition that is created from the given state, labeled with the given event and leading to the given state. If the (from,event) transition already exists in the life-cycle, it is overwritten with the given to state.- Parameters:
from
- the source state of the transitionevent
- the event causing the transitionto
- the target state of the transition- Returns:
- true, if the life-cycle changed
- Since:
- 2.0
-
containsFrom
public boolean containsFrom(ActivationState state)
Check that the life-cycle contains a transition from the given state.- Parameters:
state
-- Returns:
- true, if there is a transition from the given state, false otherwise
-
containsTo
public boolean containsTo(ActivationState state)
Check that the life-cycle contains a transition to the given state.- Parameters:
state
-- Returns:
- true, if there is a transition to the given state, false otherwise
-
copyOf
public static ActivationLifeCycle copyOf(ActivationLifeCycle lifeCycle)
Creates a complete copy of the life-cycle- Parameters:
lifeCycle
- the life-cycée to be copied- Returns:
- the copy of the life-cycle
-
create
public static ActivationLifeCycle create(ActivationState inactiveState)
-
getStateTransitions
public java.util.Set<ActivationLifeCycle.Transition> getStateTransitions()
Returns a copy of the transition table.- Since:
- 2.0
-
getInactiveState
public ActivationState getInactiveState()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-