1
2
3
4
5
6
7
8
9 package org.jrobin.core.jrrd;
10
11
12
13
14
15
16
17 public class ConsolidationFunctionType {
18
19 private static final int _AVERAGE = 0;
20 private static final String STR_AVERAGE = "AVERAGE";
21
22
23
24
25 public static final ConsolidationFunctionType AVERAGE =
26 new ConsolidationFunctionType(_AVERAGE);
27 private static final int _MIN = 1;
28 private static final String STR_MIN = "MIN";
29
30
31
32
33 public static final ConsolidationFunctionType MIN =
34 new ConsolidationFunctionType(_MIN);
35 private static final int _MAX = 2;
36 private static final String STR_MAX = "MAX";
37
38
39
40
41 public static final ConsolidationFunctionType MAX =
42 new ConsolidationFunctionType(_MAX);
43 private static final int _LAST = 3;
44 private static final String STR_LAST = "LAST";
45
46
47
48
49 public static final ConsolidationFunctionType LAST =
50 new ConsolidationFunctionType(_LAST);
51 private int type;
52
53 private ConsolidationFunctionType(int type) {
54 this.type = type;
55 }
56
57
58
59
60
61
62
63 public static ConsolidationFunctionType get(String s) {
64
65 if (s.equalsIgnoreCase(STR_AVERAGE)) {
66 return AVERAGE;
67 }
68 else if (s.equalsIgnoreCase(STR_MIN)) {
69 return MIN;
70 }
71 else if (s.equalsIgnoreCase(STR_MAX)) {
72 return MAX;
73 }
74 else if (s.equalsIgnoreCase(STR_LAST)) {
75 return LAST;
76 }
77 else {
78 throw new IllegalArgumentException("Invalid ConsolidationFunctionType");
79 }
80 }
81
82
83
84
85
86
87
88 public boolean equals(Object o) {
89
90 if (!(o instanceof ConsolidationFunctionType)) {
91 throw new IllegalArgumentException("Not a ConsolidationFunctionType");
92 }
93
94 return (((ConsolidationFunctionType) o).type == type)
95 ? true
96 : false;
97 }
98
99
100
101
102
103
104 public String toString() {
105
106 String strType;
107
108 switch (type) {
109
110 case _AVERAGE:
111 strType = STR_AVERAGE;
112 break;
113
114 case _MIN:
115 strType = STR_MIN;
116 break;
117
118 case _MAX:
119 strType = STR_MAX;
120 break;
121
122 case _LAST:
123 strType = STR_LAST;
124 break;
125
126 default :
127 throw new RuntimeException("This should never happen");
128 }
129
130 return strType;
131 }
132 }