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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use super::ItemState;
use ::dot::{Fill, ArrowShape, Side};
#[derive(Debug, Copy, Clone)]
pub enum Relation {
Association,
Aggregation,
Composition,
Realization,
Dependency,
None,
}
impl Relation {
pub fn as_style(&self) -> ArrowShape {
match self {
&Relation::Association => ArrowShape::Vee(Side::Both),
&Relation::Dependency => ArrowShape::Vee(Side::Both),
&Relation::Aggregation => ArrowShape::Diamond(Fill::Open, Side::Both),
&Relation::Composition => ArrowShape::Diamond(Fill::Filled, Side::Both),
&Relation::Realization => ArrowShape::Normal(Fill::Open, Side::Both),
&Relation::None => ArrowShape::NoArrow,
}
}
}
impl <'a>From<(&'a ItemState<'a>, &'a ItemState<'a>)> for Relation {
fn from((left, right): (&'a ItemState<'a>, &'a ItemState<'a>)) -> Relation {
if left.is_composition(right) {
Relation::Composition
} else if left.is_aggregation(right) {
Relation::Aggregation
} else if left.is_dependency(right) {
Relation::Dependency
} else if left.is_association(right) {
Relation::Association
} else if left.is_realization(right) {
Relation::Realization
} else {
Relation::None
}
}
}