Previous Table of Contents Next


5.5.3 OCL Representation of Expressions Constraints


   [C-5-1] A FeatureNode that has parameters other than the “this? parameter represents a Feature that is also an Operation.

   context FeatureNode inv:

   if self.feature.ownerScope = #instance then self.argument->size > 1 implies self.feature.oclIsKindOf(Operation) else self.argument->size > 0 implies self.feature.oclIsKindOf(Operation)

   endif

   [C-5-2] If the FeatureNode represents an instance-scope feature, the first argument is a “this? or “self? argument; that is, the object invoking the feature. The convention is enforced by checking that the type of the first argument is the same as the type of the feature.

   context FeatureNode inv:

   self.feature.ownerScope = #instance implies self.argument->first.type.allFeatures->includes(self.feature)

   [C-5-3] If the FeatureNode represents a BehavioralFeature, the number of arguments must be equal to the number of the BehavioralFeature’s parameters, plus one for the “this? parameter if the BehavioralFeature is of instance scope.

   context FeatureNode inv:

   self.feature.oclIsKindOf(BehavioralFeature) implies (if self.feature.ownerScope = #instance then self.argument->size = self.feature.oclAsType(BehavioralFeature).parameters->size + 1 else self.argument->size = self.feature.oclAsType(BehavioralFeature).parameters->size endif)

   [C-5-4] If the FeatureNode represents a BehavioralFeature, the types of the arguments must match, in order, the types of the parameters, allowing for the optional presence of a leading “this? parameter.

   context FeatureNode inv:

   self.feature.oclIsKindOf(BehavioralFeature) implies (if self.feature.ownerScope = #instance then self.argument->forAll(arg : Integer |

    self.argument->at(arg + 1) .allSuperTypes.union(self.argument.oclType)-> includes(self.feature.oclAsType(BehavioralFeature) .parameters->at(arg))

   else self.argument->forAll(arg : Integer |

    self.argument->at(arg) .allSuperTypes.union(self.argument.oclType)-> includes(self.feature.oclAsType(BehavioralFeature) .parameters->at(arg))

   endif)