1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package moe.yuuta.umlgen
/**
* Indicate an associate relationship, from one class to another, with lower / upper bonds and whether it is a partOf
* relation.
*/
@JvmRecord
data class AssociateRelation(val from: String,
val to: String,
val lower: Int,
val upper: Int,
val partOf: Boolean) {
/**
* Destruct the params.
*/
constructor(from: String, to: String, params: AssocAnnotationParams):
this(from, to, params.lower, params.upper, params.partOf)
/**
* Return the label to be put at arrow head.
* For lower == upper == 1, just returns "" because it's the default association.
* For upper == infinity (-1), return lower..*
* Otherwise, return lower..upper.
*/
fun head(): String =
if (lower == upper && upper == 1) {
""
} else if (upper == -1) {
"${lower}..*"
} else {
"${lower}..${upper}"
}
}
|