You define instance of objects using the object keywords.
@startuml
object firstObject
object "My Second Object" as o2
@enduml
Relations between objects
Relations between objects are defined using the following symbols :
Type
Symbol
Image
Extension
<|--
Composition
*--
Aggregation
o--
It is possible to replace -- by .. to have a dotted line. Knowing those rules, it is possible to draw the following drawings. It is possible a add a label on the relation, using : followed by the text of the label. For cardinality, you can use double-quotes "" on each side of the relation.
You can define a map table or associative array, with map keyword and => separator.
@startuml
map CapitalCity {
UK => London
USA => Washington
Germany => Berlin
}
@enduml
@startuml
map "Map **Contry => CapitalCity**" as CC {
UK => London
USA => Washington
Germany => Berlin
}
@enduml
@startuml
map "map: Map<Integer, String>" as users {
1 => Alice
2 => Bob
3 => Charlie
}
@enduml
And add link with object.
@startuml
object London
map CapitalCity {
UK *-> London
USA => Washington
Germany => Berlin
}
@enduml
@startuml
object London
object Washington
object Berlin
object NewYork
map CapitalCity {
UK *-> London
USA *--> Washington
Germany *---> Berlin
}
NewYork --> CapitalCity::USA
@enduml