KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tirsen > nanning > samples > prevayler > Identity


1 package com.tirsen.nanning.samples.prevayler;
2
3 import com.tirsen.nanning.attribute.Attributes;
4
5 import java.io.Serializable JavaDoc;
6
7 /**
8  * TODO document Identity
9  *
10  * @author <a HREF="mailto:jon_tirsen@yahoo.com">Jon Tirsen</a>
11  * @version $Revision: 1.20 $
12  */

13 public class Identity implements Serializable JavaDoc {
14     static final long serialVersionUID = 716500751463534855L;
15
16     private Class JavaDoc objectClass;
17     private Object JavaDoc identifier;
18
19     public Identity(Class JavaDoc objectClass, Object JavaDoc identifier) {
20         this.objectClass = objectClass;
21         this.identifier = identifier;
22     }
23
24     public Class JavaDoc getObjectClass() {
25         return objectClass;
26     }
27
28     public Object JavaDoc getIdentifier() {
29         return identifier;
30     }
31
32     public boolean equals(Object JavaDoc o) {
33         if (this == o) return true;
34         if (!(o instanceof Identity)) return false;
35
36         final Identity identity = (Identity) o;
37
38         if (!identifier.equals(identity.identifier)) return false;
39         if (!objectClass.equals(identity.objectClass)) return false;
40
41         return true;
42     }
43
44     public int hashCode() {
45         int result;
46         result = objectClass.hashCode();
47         result = 29 * result + identifier.hashCode();
48         return result;
49     }
50
51     public String JavaDoc toString() {
52         return this + "[objectClass=" + objectClass + ",identifier=" + identifier + "]";
53     }
54
55 }
56
Popular Tags