Examples

Consider a simple data model Persons containing just one class Person, with one attribute age of type Integer and a self-association whose association-ends are friendsOf (x is a friend of y) and friendTo (y is considered a friend by x).

  entity Person {
    Integer age
    Set(Person) friendsOf oppositeTo friendsFor
    Set(Person) friendsFor oppositeTo friendsOf
  }

Consider the following set of assertions:

  1. Person.allInstances()->forAll(p|p.age>18)
  2. Person.allInstances()->exists(p|p.age<=18)
  3. Person.allInstances()->exists(p|p.age.oclIsUndefined())
  4. Person.allInstances()->exists(p|p.oclIsUndefined())
  5. Person.allInstances()->forAll(p|p.oclIsUndefined())
  6. Person.allInstances()->notEmpty()
  7. Person.allInstances()->collect(p|p.age)->asSet()->exists(a|a.oclIsUndefined())
  8. Person.allInstances()->any(p|p.age>16).oclIsUndefined()
  9. Person.allInstances()->any(p|p.age>16).age.oclIsInvalid()
  10. not(Person.allInstances()->any(p|p.age<16).age.oclIsInvalid())