1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sourceforge.domian.specification;
17
18
19 import static java.lang.Boolean.TRUE;
20
21
22
23
24
25
26
27
28
29
30 enum RelationalOperator {
31
32 EQUAL("="),
33 NOT_EQUAL("<>"),
34 LESS_THAN("<"),
35 LESS_THAN_OR_EQUAL("=<"),
36 GREATER_THAN(">"),
37 GREATER_THAN_OR_EQUAL(">="),
38 MUCH_LESS_THAN("<<"),
39 MUCH_GREATER_THAN(">>");
40
41
42 final static Boolean DO_INVERT = TRUE;
43 final static Boolean DO_NOT_INVERT = !DO_INVERT;
44
45
46 private String sqlCompliantSymbolRepresentation;
47
48 private RelationalOperator(final String sqlCompliantSymbolRepresentation) {
49 this.sqlCompliantSymbolRepresentation = sqlCompliantSymbolRepresentation;
50 }
51
52
53
54 RelationalOperator getInvertedBinaryRelation() {
55 switch (this) {
56 case EQUAL:
57 return NOT_EQUAL;
58
59 case NOT_EQUAL:
60 return EQUAL;
61
62 case LESS_THAN:
63 return GREATER_THAN_OR_EQUAL;
64
65 case LESS_THAN_OR_EQUAL:
66 return GREATER_THAN;
67
68 case GREATER_THAN:
69 return LESS_THAN_OR_EQUAL;
70
71 case GREATER_THAN_OR_EQUAL:
72 return LESS_THAN;
73
74 default:
75 throw new UnsupportedOperationException("Inverted binary relation " + this.name() + " is not defined");
76 }
77 }
78
79 @Override
80 public String toString() {
81 return this.sqlCompliantSymbolRepresentation;
82 }
83 }