The placement of a guard in the UML metamodel is shown in Figure 33. The following well-formedness rule must hold.
In order to state the rule a number of additional operations are defined.
The rule also defines the value of the contextual Classifier.
context ExpressionInOcl
inv: not self.guard.transition.getStateMachine().context.oclIsUndefined()
-- A
and
self.guard.transition.getStateMachine().context.oclIsKindOf(Classifier)
-- B
implies
contextualClassifier =
self.guard.transition.getStateMachine().context.oclAsType(Classifier)
and
self.bodyExpression.type.name = 'Boolean'
[2] Inside an guard the use of @pre is not allowed.
context
ExpressionInOcl
inv: --