I have an enumeration class that has a method in the class body, how do I represent this in a UML class diagram? Is the following a valid way? (It seems reasonable but I couldn't find anyone doing this online.)
In UML an enumeration is a classifier, so it can have operations.
As strange as it feels, the compartment with the litterals should be below the compartment with the operations (see UML 2.5 specifications, section 10.2.4, emphasis added by me):
The name of the Enumeration is placed in the upper compartment with the keyword «enumeration» above or before the name. A list of EnumerationLiterals may be placed, one to a line, in a compartment named “literals” below the operations compartment. The attributes and operations compartments may be suppressed, and typically are suppressed and empty.
Yes, that would be ok. An UML Enumeration is a DataType and that can have operations as well. See p. 165 of UML 2.5. And on p. 166:
A compartment listing the Operations is placed below the attribute compartment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With