OCL sample details

This sample model, which is based on a subset of the Company/Employee domain, illustrates the OCL capabilities listed in the following table.
Capability Location in sample model
Invariant constraints EmployeeConstraints, PersonConstraints
Operation precondition, post-condition, and body condition constraints
  • @pre notation in post-conditions
  • Result notation in post-conditions and body conditions
CompanyConstraints, EmployeeConstraints, PersonConstraints
Iterator expressions:
  • select, forAll
CompanyConstraints
Type casting:
  • oclIsKindOf()
  • oclAsType()
CompanyConstraints, Stereotypes
Referencing enumeration literals EmployeeConstraints
Association navigation EmployeeConstraints
Qualified association navigation CompanyConstraints
Association classes
  • Navigation through the association class
  • Navigation to the association class from either end
  • Navigation from the association class to an end
CompanyConstraints, EmployeeConstraints
let expressions CompanyConstraints, PersonConstraints, Stereotypes
Message expressions asserting that a message was sent CompanyConstraints
Message expressions iterating the sent messages PersonConstraints
Using OCL for constraints in UML profiles Stereotypes
Referencing types in other packages Stereotypes
allInstances() expressions Stereotypes
if-then-else-endif expressions Stereotypes
Unspecified value expressions PersonConstraints
oclIsInState() operation CompanyConstraints
Ad hoc metamodel constraints Classes diagram

Feedback