I have a class Properties
with two properties:
kind
: Kind
config
: Config
with Kind
as enum type with some string in it.
What's contained in Config
depends on the value of kind
.
How can I model that in UML?
If I have, for instance, an kind
value of "Service" the config
interface will be implemented as ServiceConfig
. Would it be enough to add a constraint
annotation on the connector between Config
and ServiceConfig
?
You model that with a constraint. This can be attached to either the class or the property itself. I can't write OCL but that would be the most formal way. However, a plain text enclosed in {
braces }
will do. See also https://www.uml-diagrams.org/constraint.html
RE your edit:
The Config
interface is realized by two classes (bottom right). The constraint just tells what at runtime has to be done in order to instantiate config
. Of course it's missing details like what shall happen if at runtime kind
will dynamically change etc.