umlstaruml

I'm confused with regards to how to model my class Enum which has two class Enum inside of it in a UML diagram


How would I model my class diagraman where Inside said class I create two more classes? Here is my code in kotlin:

class Enum {

    enum class Electrodoméstico{
        Lavadora,
        Microondas,
        Refrigerador
    }
     enum class Colores{
        Blanco,
        Negro,
        Gris
    }
}

I also have to mention that my class Enum is in association with my super class Electrodoméstico where I implement my enum classes Color and Electrodoméstico.

Heres an image of my diagram. UML class diagram


Solution

  • The UML 2.5 spec states this on p. 100:

    If a Classifier has ownedMembers that are Classifiers (including Behaviors – see 13.2), a conforming tool may provide the option to show the owned Classifiers, and relationships between them, diagrammatically nested within a separate compartment of the owning Classifier’s rectangle. Unless otherwise specified, the name of such a compartment shall be derived from the corresponding metamodel property, pluralized if that property has multiplicity greater than 1. So, for example, a compartment showing the contents of the property nestedClassifier for a Class (see 11.4.2) shall be called “nested classifiers;” a compartment showing the contents of the property ownedBehavior for a BehavioredClassifier shall be called “owned behaviors.”

    I'm using EA for modeling which allows to enlarge the class frame to fit the nested enums inside. However, it does not allow to create a named compartment. But honestly the rendering will be obvious for any reader also without the label.

    You could as well just abstract the whole thing. There is probably no force to have the enums encapsulated. So you could well model it as you did with associations. Your code would then just be some implementation variant.