public final class SmcTransition extends SmcElement implements java.lang.Comparable<SmcTransition>
guard
. This is done because
a transition may appear multiple times in a state with
different conditional guards. The only requirement is that
the transition use the same name and parameters. Two
transitions with the name name but different parameters is
considered to be different transitions.SmcElement.TransType
_lineNumber, _name, NIL_STATE
Constructor and Description |
---|
SmcTransition(java.lang.String name,
java.util.List<SmcParameter> parameters,
int transId,
int lineNumber,
SmcState state)
Creates a transitions instance with the given name,
parameters, line number and owning state.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(SmcVisitor visitor)
Calls the visitor's visit method for this finite state
machine element.
|
void |
addGuard(SmcGuard guard)
Adds a guard to the list.
|
static int |
compareParams(java.util.List<SmcParameter> p1,
java.util.List<SmcParameter> p2)
Returns an integer value <, equal to, or > zero
based on whether
p1 is <, equal to, or >
p2 . |
int |
compareTo(SmcTransition trans)
Returns an interger value <, equal to or > than
zero if
this transition is <, = or > than
trans . |
int |
compareTo(java.lang.String name,
java.util.List<SmcParameter> parameters)
Returns an interger value <, equal to or > than
zero if
this transition's name and parameters are
<, = or > than name and parameters . |
boolean |
equals(java.lang.Object obj)
Returns
true if obj is a
non-null SmcTransition instance with the same name
and parameters; false otherwise. |
java.util.List<SmcGuard> |
getGuards()
Returns the guard list.
|
int |
getIdentifier()
Returns the unique transition identifier.
|
java.util.List<SmcParameter> |
getParameters()
Returns the transition parameters.
|
SmcState |
getState()
Returns the transitions owning state.
|
boolean |
hasCtxtReference()
Returns
true if this transition references the
ctxt local variable and false otherwise. |
int |
hashCode()
Returns the unique transition identifier.
|
boolean |
hasNonNilEndState()
Returns
true if this transition has a guard with a
non-nil end state and false otherwise. |
java.lang.String |
toString()
Returns the transition text representation.
|
getLineNumber, getName, merge
public SmcTransition(java.lang.String name, java.util.List<SmcParameter> parameters, int transId, int lineNumber, SmcState state)
name
- transition name.parameters
- transition parameters.transId
- the assigned transition identifier.lineNumber
- where this transition appears in the .sm
file.state
- transition appears in this state.public void accept(SmcVisitor visitor)
accept
in class SmcElement
visitor
- The visitor instance.SmcVisitor
public int compareTo(SmcTransition trans)
this
transition is <, = or > than
trans
. This compararison is based on the
transition name first and, if equal, then on the
parameters.compareTo
in interface java.lang.Comparable<SmcTransition>
trans
- the compared transition instance.this
transition is <, = or > than
trans
.public int getIdentifier()
public SmcState getState()
public java.util.List<SmcParameter> getParameters()
public java.util.List<SmcGuard> getGuards()
public boolean hasCtxtReference()
true
if this transition references the
ctxt
local variable and false
otherwise.true
if this transition references the
ctxt
local variable and false
otherwise.public boolean hasNonNilEndState()
true
if this transition has a guard with a
non-nil
end state and false
otherwise.true
if this transition has a guard with a
non-nil
end state and false
otherwise.public void addGuard(SmcGuard guard)
guard
- add this guard.public boolean equals(java.lang.Object obj)
true
if obj
is a
non-null SmcTransition
instance with the same name
and parameters; false
otherwise.equals
in class java.lang.Object
obj
- the compared object.true
if obj
is a
non-null SmcTransition
instance with the same name
and parameters.public int hashCode()
hashCode
in class java.lang.Object
public int compareTo(java.lang.String name, java.util.List<SmcParameter> parameters)
this
transition's name and parameters are
<, = or > than name
and parameters
.name
- transition name.parameters
- transition parameters.this
transition's name and parameters are
<, = or > than name
and parameters
.public java.lang.String toString()
toString
in class java.lang.Object
public static int compareParams(java.util.List<SmcParameter> p1, java.util.List<SmcParameter> p2)
p1
is <, equal to, or >
p2
. The comparison is based on List.size()
first and, if the list sizes are equal, on comparing each
SmcParameter
in turn.p1
- the first parameter list.p2
- the second parameter list.Copyright © 2015. Charles W. Rapp. All Rights Reserved. Use is subject to license terms.