16.4.  Enumeration

An enumeration is a primitive datatype that can have a fixed short list of values. It has no attributes, and any operations on them must have no side-effects. A useful analogy is the primitive datatype boolean in a language like Java. The boolean stands on its own -it has no inner structure. There are operations (for example logical xor) on the booleans, but when I perform true xor true the result is a new boolean, and the original 2 booleans “true” are unchanged by the exercise.

Within UML 1.4, Enumeration is a sub-class of the DataType metaclass.

The big difference with other DataTypes, is that an Enumeration has EnumerationLiterals. E.g. the Enumeration “boolean” is defined as having 2 EnumerationLiterals, “true” and “false”.

Within ArgoUML new enumerations may be created using the New Enumeration button on the property tabs of the model and packages (in which case the new enumeration is restricted in scope to the package), as well as the properties tab for datatype and enumeration. Enumerations can also be created with the tool in the diagram toolbar of a class diagram.

The UML 1.4 standard allows user defined enumerations to be placed on class diagrams to define their inheritence structure. This is also possible in ArgoUML. It is represented on the diagram by a box with three compartments, of which the top one is marked with «enumeration», and contains the name. The middle compartment shows the enumeration literals. The lower one contains operations.

16.4.1.  Enumeration Details Tabs

The details tabs that are active for enumerations are as follows.

ToDoItem

Standard tab.

Properties

See Section 16.4.2, “ Enumeration Property Toolbar and Section 16.4.3, “ Property Fields For Enumeration below.

Documentation

Standard tab. See Section 13.4, “ Documentation Tab.

Presentation

Standard tab.

Source

Standard tab.

Stereotype

Standard tab. The UML metamodel has the following stereotypes defined by default for a Classifier, which also apply to an Enumeration:

  • metaclass (from the superclass, Classifier).

  • powertype (from the superclass, Classifier).

  • process (from the superclass, Classifier).

  • thread (from the superclass, Classifier).

  • utility (from the superclass, Classifier).

Tagged Values

Standard tab. In the UML metamodel, Enumeration has no standard tagged values defined.

16.4.2.  Enumeration Property Toolbar

Go up

Navigate up through the composition structure.

New datatype

This creates a new datatype (see Section 18.6, “ Class) within the same package as the current enumeration.

New enumeration

This creates a new enumeration within the same namespace as the current enumeration, navigating immediately to the properties tab for new enumeration.

New enumeration literal

This creates a new enumeration literal within the enumeration, navigating immediately to the properties tab for that literal.

New Operation

This creates a new operation within the enumeration, navigating immediately to the properties tab for that operation.

New Stereotype

This creates a new Stereotype (see Section 16.6, “ Stereotype) within the same package as the enumeration, navigating immediately to the properties tab for that stereotype.

Delete from Model

This deletes the datatype from the model.

16.4.3.  Property Fields For Enumeration

Name

Text box. The name of the enumeration. The primitive enumerations all have lower case names, but there is no formal convention.

[Note]Note

The default name supplied for a newly created datatype is the empty string “”. Enumerations with empty string names will appear with the name (Unnamed Enumeration) in the explorer.

Namespace

Drop down selector with navigation button. Allows changing the namespace for the enumeration. This is the composition hierarchy.

Modifiers

Check box, with entries Abstract, Leaf and Root.

  • Abstract is used to declare that this enumeration cannot be instantiated, but must always be specialized.

  • Leaf indicates that this enumeration can have no further sub-types, while Root indicates it is a top level enumeration.

Visibility

Radio box, with entries public, private, protected, and package.

Records the visibility for the Enumeration.

Client Dependencies

Text area. Lists any elements that depend on this enumeration. Button 1 double click navigates to the selected modelelement. Button 2 click brings up a pop up menu with following entry.

  • Add.... This brings up a dialog box that allows to create dependencies from other modelelements.

Supplier Dependencies

Text area. Lists any elements that this enumeration depends on. Button 1 double click navigates to the selected modelelement. Button 2 click brings up a pop up menu with the following entry.

  • Add.... This brings up a dialog box that allows to create dependencies to other modelelements.

Generalizations

Text area. Lists any enumeration that generalizes this enumeration.

Specializations

Text box. Lists any specialized enumerations (i.e. for which this enumeration is a generalization.

Operations

Text area. Lists all the operations defined on this enumeration. Button 1 double click navigates to the selected operation. Button 2 click brings up a pop up menu with two entries.

  • Move Up. Only available where there are two or more operations, and the operation selected is not at the top. It is moved up one.

  • Move Down. Only available where there are two or more operations listed, and the operation selected is not at the bottom. It is moved down one.

See Section 18.8, “ Operation for details of operations.

[Caution]Caution

ArgoUML treats all operations as equivalent. Any operations created here will use the same mechanism as operations for classes. Remember that operations on enumerations must have no side effects (they are read-only). This means the query modifier must be checked for all operations.

Literals

Text area. Lists all the enumeration literals defined for this enumeration. Button 1 double click navigates to the selected literal, button 2 click brings up a pop up menu with two entries.

  • Move Up. Only available where there are two or more literals, and the literal selected is not at the top. It is moved up one.

  • Move Down. Only available where there are two or more literals listed, and the literal selected is not at the bottom. It is moved down one.