1 package org.apache.torque.util.functions;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 /***
23 * A typesafe enum of SQL Standard function names. Used by the
24 * FunctionFactory and (eventually) the DB Adaptors to create SQLFunction
25 * objects.
26 *
27 * @author <a href="mailto:greg.monroe@dukece.com">Greg Monroe</a>
28 * @version $Id
29 */
30 public class FunctionEnum implements java.io.Serializable
31 {
32 /***
33 * Serial version
34 */
35 private static final long serialVersionUID = 5963149836513364800L;
36
37 /*** The AVG( [Distinct] EXPR ) function id */
38 public static final FunctionEnum AVG =
39 new FunctionEnum("AVG");
40 /*** The SUM( [Distinct] EXPR ) function id */
41 public static final FunctionEnum SUM =
42 new FunctionEnum("SUM");
43 /*** The MAX( [Distinct] EXPR ) function id */
44 public static final FunctionEnum MAX =
45 new FunctionEnum("MAX");
46 /*** The MIN( [Distinct] EXPR ) function id */
47 public static final FunctionEnum MIN =
48 new FunctionEnum("MIN");
49 /*** The COUNT( [Distinct] EXPR ) function id */
50 public static final FunctionEnum COUNT =
51 new FunctionEnum("COUNT");
52
53 private final String s;
54
55 /***
56 * This is a static only class.
57 * @param s
58 */
59
60 private FunctionEnum(String s)
61 {
62 this.s = s;
63 }
64
65 public final String toString()
66 {
67 return s;
68 }
69
70 /***
71 * returns whether o is the same FunctionEnum as this object.
72 * Two FunctionEnums are considered equal if they contain the same String.
73 * @param o the object to compare the FunctionEnum with.
74 */
75 public boolean equals(Object o)
76 {
77 if (o == null)
78 {
79 return false;
80 }
81
82 if (!(o instanceof FunctionEnum))
83 {
84 return false;
85 }
86
87 FunctionEnum otherEnum = (FunctionEnum) o;
88
89
90
91
92
93 return (otherEnum.s == null)
94 ? (s == null)
95 : otherEnum.s.equals(s);
96 }
97
98 /***
99 * returns a hashcode for this object which is consistent with equals()
100 */
101 public int hashCode()
102 {
103 return (s == null)
104 ? 0
105 : s.hashCode();
106 }
107 }