1 9 package org.jrobin.core.jrrd; 10 11 17 public class ConsolidationFunctionType { 18 19 private static final int _AVERAGE = 0; 20 private static final String STR_AVERAGE = "AVERAGE"; 21 22 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 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 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 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 63 public static ConsolidationFunctionType get(String s) { 64 65 if (s.equalsIgnoreCase(STR_AVERAGE)) { 66 return AVERAGE; 67 } else if (s.equalsIgnoreCase(STR_MIN)) { 68 return MIN; 69 } else if (s.equalsIgnoreCase(STR_MAX)) { 70 return MAX; 71 } else if (s.equalsIgnoreCase(STR_LAST)) { 72 return LAST; 73 } else { 74 throw new IllegalArgumentException ("Invalid ConsolidationFunctionType"); 75 } 76 } 77 78 84 public boolean equals(Object o) { 85 86 if (!(o instanceof ConsolidationFunctionType)) { 87 throw new IllegalArgumentException ("Not a ConsolidationFunctionType"); 88 } 89 90 return (((ConsolidationFunctionType) o).type == type) 91 ? true 92 : false; 93 } 94 95 100 public String toString() { 101 102 String strType; 103 104 switch (type) { 105 106 case _AVERAGE: 107 strType = STR_AVERAGE; 108 break; 109 110 case _MIN: 111 strType = STR_MIN; 112 break; 113 114 case _MAX: 115 strType = STR_MAX; 116 break; 117 118 case _LAST: 119 strType = STR_LAST; 120 break; 121 122 default : 123 throw new RuntimeException ("This should never happen"); 124 } 125 126 return strType; 127 } 128 } 129 | Popular Tags |