The append(n:int) operation and its Activity method Append

Gallery
Tutorial

The operation append(n:int) of the class Number has an Activity Append with matching Parameters assigned as its 'method':

Click on the image to view it full size
The Number manages an attribute Property for carrying an ordered list of telephone digits:
n:int[0..*] {ordered,nonunique}
Whether a StructuralFeature is declared to be isOrdered or isUnique has big consequences for the use of AddStructuralFeatureAction!

The Append Activity receives a (mandatory) digit as Parameter n:int[1] (with a corresponding ActivityParameterNode). It uses a ForkNode to send this digit value to both a diagnostic CallBehaviorAction (that invokes an OpaqueBehavior to print the digit) and to an AddStructuralFeatureAction (which is also where the forked flows end up syncing).

We want to accumulate the digits, so 'isReplaceAll' is set to false on the AddStructuralFeatureAction. The StructuralFeature within Number of interest n:int[0..*] is an ordered list, and its elements are NOT unique (because sometimes a phone number can contain the same digit more than once), so the AddStructuralFeatureAction needs an 'insertAt' Pin.

From the UML-2.5.1 spec:

Adding a value to an ordered StructuralFeature requires an insertion point for the new value given in the insertAt InputPin, which is required for ordered StructuralFeatures when isReplaceAll is false and omitted for unordered StructuralFeatures.
A value of unlimited (“*”) for the insertion point means to insert the new value at the end of the sequence.

We see how these accumulated digits are printed next

Up next
Notes
Snippets (quotes/extracts)
Visit also
Visit also (backlinks)
Related slides (includes other tutorials)
Related slides (backlinks, includes other tutorials)