Is it possible to express constraint on the tagged value of an applied stereotype in UML/OCL?

168 Views Asked by At

For example, let's consider the following UML diagram: enter image description here

The model has to be valid only if for all of the instances of Block1, the instance of Block1::unit_of_press is the same instance of the tagged value unit of the actual type of Block1::press

Is it possible to express such a constraint in OCL?

1

There are 1 best solutions below

0
On

Yes, it is possible to access the tagged values of an applied stereotype. See Finding All Elements with a Given Tag as a starting point. From there you can assert what must be true about the tagged value.

In case that web page becomes unavailable, an example is:

self.allOwnedElements()
->select(e | e.getValue(e.getAppliedStereotype('Ecore::EAttribute'), 'isTransient') = true)

(Thanks to Rafael Chaves, Vladimir Orany, and Bjoern Sundin.)