KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > pojo > test > IdObject


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.cache.pojo.test;
8
9 /**
10  * Key object that overrides the hashCode that can cause problem for aop.
11  */

12 // We are using JDK1.5 annotation.
13
@org.jboss.cache.pojo.annotation.Replicable
14 public class IdObject
15 {
16
17    private String JavaDoc id;
18
19    public IdObject()
20    {
21    } // IdObject
22

23    public IdObject(String JavaDoc aId)
24    {
25       id = aId;
26    } // IdObject
27

28
29    public String JavaDoc toString()
30    {
31       return id;
32    } // toString
33

34    public boolean equals(Object JavaDoc aObject)
35    {
36       boolean result = false;
37
38       if ((aObject != null) &&
39               (aObject.getClass().getName().equals(this.getClass().getName())))
40       {
41          if (id.equals(((IdObject) aObject).id))
42          {
43             result = true;
44          } // if
45
} // if
46

47       return result;
48    } // equals
49

50    public int hashCode()
51    {
52       return id.hashCode();
53    } // hashCode
54
} // class IdObject
55

56
Popular Tags