01: /**
02: * $RCSfile$
03: * $Revision: 42 $
04: * $Date: 2004-10-21 00:28:12 -0700 (Thu, 21 Oct 2004) $
05: *
06: * Copyright (C) 2004 Jive Software. All rights reserved.
07: *
08: * This software is published under the terms of the GNU Public License (GPL),
09: * a copy of which is included in this distribution.
10: */package org.jivesoftware.util;
11:
12: /**
13: * A type safe enumeration object. Used for indicating distinct states
14: * in a generic manner. Most child classes should extend Enum and
15: * create static instances.
16: *
17: * @author Iain Shigeoka
18: */
19: public class Enum {
20: private String name;
21:
22: protected Enum(String name) {
23: this .name = name;
24: }
25:
26: /**
27: * Returns the name of the enum.
28: *
29: * @return the name of the enum.
30: */
31: public String getName() {
32: return name;
33: }
34:
35: public boolean equals(Object object) {
36: if (this == object) {
37: return true;
38: } else if ((this .getClass().isInstance(object))
39: && name.equals(((Enum) object).name)) {
40: return true;
41: } else {
42: return false;
43: }
44: }
45:
46: public int hashCode() {
47: return name.hashCode();
48: }
49:
50: public String toString() {
51: return name;
52: }
53: }
|