Advanced Systems Design with Java, UML and MDA

In this chapter we describe the UML constraint language, OCL, and a subset, LOCA, of OCL. OCL is a means to express more complex properties of diagram elements, and interrelationships between elements. OCL is defined for version 2.0 of the UML [34], and this is the version we will base our own constraint language, LOCA, on.
In a class diagram, constraints are used to:
Express invariants of classes - properties relating the attributes and rolenames of the class, which are expected to be true for each object of the class, at all times when the object is not executing a method.
Express preconditions of operations of a class - properties of the object responding to the operation, and of the operation input parameters, which are required to be true when it starts execution.
Express postconditions of operations of a class - properties of the object responding to the operation, and of the operation output parameter result, if present, which are required to be true when the operation completes execution.
To these we add a further category:
Properties which relate the state of several classes, in particular, the states of objects of these classes which are linked by specific associations between them.
Full OCL notation is itself a complex language [34] which contains four different forms of collection: sets, ordered sets (sequences without duplicates), sequences and bags (multisets), many operations on these and on single valued data, quantifiers, and the capability for auxiliary and...