-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathRelationDirection.java
39 lines (35 loc) · 1018 Bytes
/
RelationDirection.java
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
package org.umlgraph.doclet;
/**
* The possibile directions of a relation given a reference class (used in
* context diagrams)
*/
public enum RelationDirection {
NONE, IN, OUT, BOTH;
/**
* Adds the current direction
* @param d
* @return
*/
public RelationDirection sum(RelationDirection d) {
// Handle same and nones first:
return (this == d || d == NONE) ? this : //
this == NONE ? d : BOTH; // They are different and not none.
}
/**
* Returns true if this direction "contains" the specified one, that is,
* either it's equal to it, or this direction is {@link #BOTH}
* @param d
* @return
*/
public boolean contains(RelationDirection d) {
return this == BOTH ? true : (d == this);
}
/**
* Inverts the direction of the relation. Turns IN into OUT and vice-versa, NONE and BOTH
* are not changed
* @return
*/
public RelationDirection inverse() {
return this == IN ? OUT : this == OUT ? IN : this;
}
}