8.3 Enumeration Types


An enumeration type is a special user -defined type often used as a type for attributes. It is defined within the UML class diagram by using the enumeration stereotype, as shown in Figure 8-4. The values defined in the enumeration can be used as values within an OCL expression. The notation to indicate one of the enumeration values in an OCL expression is the enumeration type name , two colons, followed by the enumeration value identifier. Note that the previous version of OCL used a different notation.

Figure 8-4. Customer class with enumeration

graphics/08fig04.gif

In Figure 8-4, the Customer class is shown again. Now we have changed the attribute isMale to an attribute gender . The following invariant states that male Customer s must be approached using the title 'Mr.' .

  context  Customer  inv  : gender = Gender::male implies title = 'Mr.' 

The only operators available on enumeration values are the equality and inequality operators. They are denoted by = and <>, respectively.



Object Constraint Language, The. Getting Your Models Ready for MDA
The Object Constraint Language: Getting Your Models Ready for MDA (2nd Edition)
ISBN: 0321179366
EAN: 2147483647
Year: 2003
Pages: 137

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net