There are different notions of final that are all represented in different ways:
final definition, i.e. it cannot be overridden in sub-classes - this corresponds to the isLeaf property of the attribute:
The isLeaf property, when true for a particular RedefinableElement, specifies that it shall have no redefinitions.
- UML 2.5 specifications, page 99
There is no official notation anymore for attributes with isLeaf=true; adding {leaf}
was the former official notation (UML 1.x) and it is still common.
final value, i.e. its value cannot be changed - this corresponds to the isReadOnly property of the attribute:
If a StructuralFeature is marked with isReadOnly true, then it may not be updated once it has been assigned an initial value. Conversely, when isReadOnly is false (the default), the value may be modified.
- UML 2.5 specifications, page 106
Notation for read-only attributes consists of appending {readOnly}
to the attribute string.
constant usually refers to a non-changeable attribute of the class itself instead of an instance (static final attribute). In UML it would have both properties mentioned above and additionally be static, which corresponds to the isStatic property:
The isStatic property specifies whether the characteristic relates to the Classifier’s instances considered individually (isStatic=false), or to the Classifier itself (isStatic=true).
- UML 2.5 specifications, page 105
Static attributes are indicated by underlining the attribute definition. Constants, as already mentioned are usually UPPERCASE, but that's just a convention.
So, to sum it up, a constant attribute FOO of type String with value "x" would look like this and be underlined in addition (which isn't supported here):
+ FOO : String = "x" {readOnly,leaf}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…