Previous Table of Contents Next


4.4.4 OCL Representation of Behavioral Constraints


4.4.4.1 Operations

   The operation hasSameSignature checks if the argument has the same signature as the instance itself.

   hasSameSignature ( b : BehavioralFeature ) : Boolean;

   hasSameSignature (b) = (self.name = b.name) and (self.parameter->size = b.parameter->size) and Sequence{ 1..(self.parameter->size) }->forAll( index : Integer |

    b.parameter->at(index).type = self.parameter->at(index).type and b.parameter->at(index).kind = self.parameter->at(index).kind )

   The operation allOperations results in a Set containing all Operations of the Classifier itself and all its inherited Operations.

   allOperations : Set(Operation);allOperations = self.allFeatures->select(f | f.ockIsKindOf(Operations))

   The operation allMethods results in a Set containing all Methods of the Classifieritself and all its inherited Methods.

   allOperations : Set(Method);allMethods = self.allFeatures->select(f | f.ockIsKindOf(Method))

4.4.4.2 Constraints

   [C-4-1] All Parameters should have a unique name.context BehavioralFeature inv:self.parameter->forAll(p1, p2 | p1.name = p2.name implies p1 =p2)

   [C-4-2] The type of the Parameters should be included in the Namespace of the Classifier.

   context BehavioralFeature inv:

   self.parameter->forAll( p | self.owner.namespace.allContents->includes (p.type) )

   [C-4-3] The number of arguments must be the same as the number of parameters ofthe Operation.context CallAction inv:self.actualArgument->size = self.operation.parameter->size

   [C-4-4] An Interface can only contain Operations.context Interface inv:self.allFeatures->forAll( f | f.oclIsKindOf( Operation ) )

   [C-4-5] An Interface cannot contain any ModelElements.context Interface inv:self.allContents->isEmpty

   [C-4-6] All Features defined in an Interface are public.context Interface inv:self.allFeatures->forAll( f | f.visibility = #public )

   [C-4-7] If the realized Operation is a query, then so is the Method.context Method inv:self.specification->isQuery implies self.isQuery

   [C-4-8] The signature of the Method should be the same as the signature of the realized Operation.context Method inv:self.hasSameSignature( self.specification )

   [C-4-9] The visibility of the Method should be the same as for the realizedOperation.context Method inv:self.visibility = self.specification.visibility

   [C-4-10] The realized Operation must be a feature (possibly inherited) of the same Classifier as the Method.context Method inv:self.owner.allOperations->includes( self.specification )

   [C-4-11] If the realized Operation has been overridden one or more times in the ancestors of the owner of the Method, then the Method must realize the latestoverriding (that is, all other operations with the same signature must be owned byancestors of the owner of the realized Operation).

context Method inv:

   self.specification.owner.allOperations->includesAll( ( self.owner.allOperations->select( op | self.hasSameSignature( op ) ) )

   [C-4-12] There may be at most one method for a given classifier (as owner of the

   method) and operation (as specification of the method) pair.

context Method inv:

   self.owner.allMethods->select( operation = self.operation )->size = 1