01: package org.umlgraph.doclet;
02:
03: /**
04: * The possibile directions of a relation given a reference class (used in
05: * context diagrams)
06: */
07: public enum RelationDirection {
08: NONE, IN, OUT, BOTH;
09:
10: /**
11: * Adds the current direction
12: * @param d
13: * @return
14: */
15: public RelationDirection sum(RelationDirection d) {
16: if (this == NONE)
17: return d;
18:
19: if ((this == IN && d == OUT) || (this == OUT && d == IN)
20: || this == BOTH || d == BOTH)
21: return BOTH;
22: return this ;
23: }
24:
25: /**
26: * Returns true if this direction "contains" the specified one, that is,
27: * either it's equal to it, or this direction is {@link #BOTH}
28: * @param d
29: * @return
30: */
31: public boolean contains(RelationDirection d) {
32: if (this == BOTH)
33: return true;
34: else
35: return d == this ;
36: }
37:
38: /**
39: * Inverts the direction of the relation. Turns IN into OUT and vice-versa, NONE and BOTH
40: * are not changed
41: * @return
42: */
43: public RelationDirection inverse() {
44: if (this == IN)
45: return OUT;
46: else if (this == OUT)
47: return IN;
48: else
49: return this;
50: }
51:
52: };
|