com.evelopers.unimod.core.stateworks
Class Transition

java.lang.Object
  extended bycom.evelopers.unimod.core.ModelElement
      extended bycom.evelopers.unimod.core.stateworks.Transition
All Implemented Interfaces:
java.io.Serializable

public class Transition
extends ModelElement

Transition abstraction. Has source and target states, trigged event, guard condition and output actions to be executed in a case of this transition chosen as transition to go.

Transition has several internal states that the following table illustrates:

 +---------------------------------------------------------------------------------+
 | state | source state set | source attached | target state set | target attached |
 +---------------------------------------------------------------------------------+
 |     1 | no               | no              | no               | no              |
 |     2 | yes              | no              | no               | no              |
 |     3 | yes              | yes             | no               | no              |
 |     4 | yes              | yes             | yes              | no              |
 |     5 | yes              | yes             | yes              | yes             |
 |     6 | no               | no              | yes              | no              |
 |     7 | no               | no              | yes              | yes             |
 |     8 | yes              | no              | yes              | yes             |
 |     9 | yes              | no              | yes              | no              |
 +---------------------------------------------------------------------------------+
 

To set source and target state and attach them, use method reconnect(com.evelopers.unimod.core.stateworks.State, com.evelopers.unimod.core.stateworks.State).

There are 4 different types of Transition because of different types of Event and Guard:

TypeEventGuardSemantics
1E1O1.X1E1 && O1.X1
2Event.ANYO1.X1E1 || E2 || .. || Ex && O1.X1 where E1..Ex are all possible event
3E1Guard.ELSEE1 && !(guard1 || guard2 || ... || guardx) where guard 1..guardx are guard conditions on all outgoing transitions with event E1
4Event.ANYGuard.ELSE(E1 && !(guard11 || guard12 || ... || guard1x)) || (E2 && !(guard21 || guard22 || ... || guard2x)) || ... || (Ey && !(guardy1 || guardy2 || ... || guardyx))

See Also:
Serialized Form

Field Summary
protected  Event event
          Trigger event.
static java.lang.String EVENT_PROPERTY
           
protected  Guard guard
          Guard condition
static java.lang.String GUARD_PROPERTY
           
static java.lang.String OUTPUT_ACTIONS_PROPERTY
           
protected  java.util.List outputActions
          List of output actions.
protected  State sourceState
          Source state
protected  State targetState
          Target state
 
Fields inherited from class com.evelopers.unimod.core.ModelElement
listeners, name, NAME_PROPERTY, stereotype, STEREOTYPE_PROPERTY
 
Constructor Summary
protected Transition(State sourceState, State targetState, Guard guard, Event event)
          Creates transition.
 
Method Summary
 void addOutputAction(Action action)
          Adds output action
 void attachSource()
           
 void attachTarget()
           
 void detachSource()
           
 void detachTarget()
           
 boolean equals(java.lang.Object o)
          Compare with another model element.
 Event getEvent()
          Returns trigged event
 Guard getGuard()
          Returns guard condition
 java.util.List getOutputActions()
          Returns output actions
 State getSourceState()
          Returns source state
 State getTargetState()
          Returns target state
 int hashCode()
          Returns model element hash code.
 void reconnect(State newSourceState, State newTargetState)
          Reconnects transition to new source and target states.
 void removeOutputAction(Action action)
          Removes output action
 void setEvent(Event newEvent)
           
 void setGuard(Guard guard)
           
 void setSourceState(State newSourceState)
          Sets new source state.
 void setTargetState(State newTargetState)
          Sets new target state.
 java.lang.String toString()
          Returns transition string representation
 
Methods inherited from class com.evelopers.unimod.core.ModelElement
accept, addPropertyChangeListener, firePropertyChange, getName, getStereotype, initListeners, removePropertyChangeListener, setName, setStereotype
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

OUTPUT_ACTIONS_PROPERTY

public static final java.lang.String OUTPUT_ACTIONS_PROPERTY
See Also:
Constant Field Values

EVENT_PROPERTY

public static final java.lang.String EVENT_PROPERTY
See Also:
Constant Field Values

GUARD_PROPERTY

public static final java.lang.String GUARD_PROPERTY
See Also:
Constant Field Values

sourceState

protected State sourceState
Source state


targetState

protected State targetState
Target state


event

protected Event event
Trigger event.


guard

protected Guard guard
Guard condition


outputActions

protected java.util.List outputActions
List of output actions. List here, because sequence of execution makes sence.

Constructor Detail

Transition

protected Transition(State sourceState,
                     State targetState,
                     Guard guard,
                     Event event)
Creates transition. Assumes that if given Conditon is null - it's Guard.TRUE_EXPR and if given Event is null - it's Event.NO_EVENT

Parameters:
sourceState - source state
targetState - target state
guard - guard guard
event - trigged event
Method Detail

reconnect

public void reconnect(State newSourceState,
                      State newTargetState)
Reconnects transition to new source and target states.
  • Detachs from source and sets new source state
  • Detachs from target and sets new target state
  • Attaches to new source state
  • Attaches to new target state

    Parameters:
    newSourceState - new source state
    newTargetState -

  • getSourceState

    public State getSourceState()
    Returns source state

    Returns:
    source state

    setSourceState

    public void setSourceState(State newSourceState)
    Sets new source state. If old source state was not null - removes this transition from outgoing transitions of source state.

    Parameters:
    newSourceState - new source state. If null, then transition will only removes itself from old source state outgoing transitions list.

    attachSource

    public void attachSource()

    detachSource

    public void detachSource()

    getTargetState

    public State getTargetState()
    Returns target state

    Returns:
    target state

    setTargetState

    public void setTargetState(State newTargetState)
    Sets new target state. If old target state was not null - removes this transition from incoming transitions of target state.

    Parameters:
    newTargetState - new target state. If null, then transition will only removes itlsef from target state incoming transitions set.

    attachTarget

    public void attachTarget()

    detachTarget

    public void detachTarget()

    getEvent

    public Event getEvent()
    Returns trigged event

    Returns:
    trigged event

    setEvent

    public void setEvent(Event newEvent)

    getGuard

    public Guard getGuard()
    Returns guard condition

    Returns:
    guard condition

    setGuard

    public void setGuard(Guard guard)

    addOutputAction

    public void addOutputAction(Action action)
    Adds output action

    Parameters:
    action - action to add

    removeOutputAction

    public void removeOutputAction(Action action)
    Removes output action

    Parameters:
    action - action to remove

    getOutputActions

    public java.util.List getOutputActions()
    Returns output actions

    Returns:
    list of output actions

    equals

    public boolean equals(java.lang.Object o)
    Description copied from class: ModelElement
    Compare with another model element.

    Specified by:
    equals in class ModelElement
    Parameters:
    o - another model element
    Returns:
    boolean

    hashCode

    public int hashCode()
    Description copied from class: ModelElement
    Returns model element hash code.

    Specified by:
    hashCode in class ModelElement
    Returns:
    hash code

    toString

    public java.lang.String toString()
    Returns transition string representation

    Overrides:
    toString in class ModelElement
    Returns:
    transition string representation