10.9 Accessing Overriden Features


Whenever features are redefined within a type, the feature of the supertypes can be accessed using the oclAsType() operation. Whenever you have a class B as a subtype of class A , and a feature f1 of both A and B , you can write

  context  B  inv  : self.oclAsType(A).f1  -- accesses the f1 feature defined in A  inv  : self.f1               -- accesses the f1 feature defined in B 

Figure 10-3 shows an example where such a construct is needed. This model fragment contains an ambiguity in the following OCL expression on class Dependency :

  context  Dependency  inv  : self.source <> self 
Figure 10-3. Accessing overridden features example

graphics/10fig03.gif

This can mean either normal association navigation, which is inherited from ModelElement , or it might mean navigation through the dotted line as an association class. Both possible navigations use the same rolename, so this is always ambiguous. Using oclAsType(), you can distinguish between them with

  context  Dependency  inv  : self.oclAsType(Dependency).source <> self 

or

  context  Dependency  inv  : self.oclAsType(ModelElement).source <> self 


Object Constraint Language, The. Getting Your Models Ready for MDA
The Object Constraint Language: Getting Your Models Ready for MDA (2nd Edition)
ISBN: 0321179366
EAN: 2147483647
Year: 2003
Pages: 137

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net