OCL statement in a class diagram | can specify what the values of attributes and associations must be |  |
can state the preconditions and postconditions of operations |  |
is a subtopic of 5.6 - More Advanced Features of Class Diagrams |  |
is a kind of OCL statement |  |
OCL statement | can be used for automatic code generation |  |
can consist of - References to role names, association names, attributes and the results of operations.
- The logical values true and false
- Logical operators such as and, or, =, >, < or <> (not equals)
- String values such as: 'a string'
- Integers and real numbers (the latter having a decimal point)
- Arithmetic operations *, /, +, -
|  |
can navigate from class to class using a dot to separate components. For example, in LinearShape, to refer to the length of the edges you can refer to edge.length. |  |
can refer to all the values in a collection using the forall operator |  |
can refer to special OCL properties of a collection itself using the -> operator |  |
can use the {ordered} constraint to indicate that an OCL collection is a sequence, which allows you refer to special properties such as first and last |  |
can use the implies operator which is true if either the left hand side is false or if both sizes are true |  |
does not have to be written on a UML diagram but can be written separately with a context specified |  |
has example {startPoint <> endPoint} constrains the two ends of a LineSegment to be different |  |
is not compiled |  |
is not executed |  |
statement | should be not more than one line long if possible |  |