Tags and keywords
Inspecting our StateMachine again, we see that it has a guard on the Transition that tests whether the accumulated number is valid by accessing the
isValid
operation on the number:Number
of the Dialer
:This transition guard has been implemented here using Action Language for Foundational UML (Alf)
[this.number.isValid()]
To learn how to access an operation on a guard without Action Language for Foundational UML (Alf) using the Action Language Helper (ALH) please visit this separate tutorial slide.
The Operation isValid()
in fact has a trivial OpaqueBehavior isValid
as its method, which uses BeanShell to test whether we have 4 digits (just for our test, we don't want to wait all day to accumulate 10 or so digits during our simulation runs).
n.size()==4
And it does not otherwise test whether the digits could be a sensible phone number:
Note again how the OpaqueBehavior seems to "magically" have access to the Property n:int[0..*]
of Number
.
So, assuming we indeed have accumulated such a valid number, the Transition will fire, and then the WhenValid
effect Behavior will be invoked, so let's examine that next