UML Class Diagram Enumeration

An enum allows you to define an entity with a list of literals in the UML class diagram. UML Enumeration values can be used by class attributes.

What is Enumeration in UML Class Diagram?

An enumeration is a complete list of all values that a given type may acquire. An enumeration is used as a type of attributes, operations, and operation parameters. Enums may be used in a flag mode to support bitwise combinations of particular values. An enumeration is depicted as a rectangular box with a name and line-separated list of items.

Enum Values

An enumeration is represented by its values. A meaningful enumeration should contain two and more values.

UML Enumeration Literal

An item of enumeration is also called enumeration literal. It is represented by its name. Optionally, a numeric or other type value for the literal may be defined.

How to Add Values to Enum

In the diagram editor, you can add other enumeration items using the context bar. First, create a new enumeration or select an existing one. Then click on the Add Item button in the context bar (usually placed below the selected enumeration). A new item will be added to the enumeration and you can enter its name.

Enumeration Relationship

An enumeration connects to a class using UML association relationship. The relationship says whether an attribute, operation, or operation parameter of the class uses the enumeration as its type.
An enumeration associated with a class (UML Class Diagram)
An enumeration associated with a class (UML Class Diagram)

Enum Association

An enum may be associated with a class or a class field (attribute, operation). If you drag (using the right mouse button) the enumeration and drop it over an attribute, it will be set as its type.

UML Enum inside Class

An enum can be defined in a class. This may be modeled using containment relationships in UML class diagram.
An enumeration nested in a class (UML Class Diagram)
An enumeration nested in a class (UML Class Diagram)

Enumeration Example

The following diagram shows a UML enum example on a UML class diagram:
Example of an enumeration in a class diagram
Example of an enumeration in a class diagram

New Comment

Comment