OCL 2.1 RTF Avatar
  1. OMG Issue

OCL21 — rewrite well-formedness

  • Key: OCL21-219
  • Legacy Issue Number: 7466
  • Status: closed  
  • Source: OpenModeling ( Jos Warmer)
  • Summary:

    We would like to be able to rewrite well-formedness rules like:
    context IfExp
    inv: self.condition.type.oclIsKindOf(Primitive) and
    self.condition.type.name = ’Boolean’
    as
    context IfExp
    inv: self.condition.type.oclIsKindOf(Primitive) and This is more clear that the first expression where the matching is done by name.
    Because the metamodel resides on a level higher than the standard library, we need a way to get access
    to the standard library elements. One solution is to define a package ’StandardLibrary’ that contains a
    Classifier called ’StdLib’, that holds the following attributes:
    • + Collection: CollectionType;
    • + Set: SetType;
    • + OrderedSet: OrderedSetType;
    • + Sequence: SequenceType;
    • + Bag: BagType;
    • + String: Primitive;
    • + OclMessage: OclMessageType;
    • + OclVoid : VoidType;
    Other solutions might be possible, but the above has been proven to work in the Octopus tool.

  • Reported: OCL 2.0b2 — Thu, 10 Jun 2004 04:00 GMT
  • Disposition: Resolved — OCL 2.1
  • Disposition Summary:

    Unfortunately the 'better' example is missing from the above text. Presumably it should read:
    context IfExp
    inv: self.condition.type.oclIsKindOf(Primitive) and self.condition.type = StdLib::Boolean
    OCL supports type literal as in a.oclIsKindOf(Boolean) so the 1.x practice of comparing types by string-valued name was a misunderstanding. It is possible to write
    inv: self.condition.type.oclIsKindOf(Primitive) and self.condition.type = Boolean
    Disposition: Closed, no change

  • Updated: Fri, 6 Mar 2015 20:58 GMT