KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > cache > test > standAloneAop > 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.test.cache.test.standAloneAop;
8
9 /**
10  * Key object that overrides the hashCode that can cause problem for aop.
11  */

12 public class IdObject{
13
14   private String JavaDoc id;
15
16   public IdObject() {
17   } // IdObject
18

19   public IdObject(String JavaDoc aId) {
20     id = aId;
21   } // IdObject
22

23
24   public String JavaDoc toString() {
25     return id;
26   } // toString
27

28   public boolean equals(Object JavaDoc aObject) {
29     boolean result = false;
30
31     if ((aObject != null) &&
32          (aObject.getClass().getName().equals( this.getClass().getName()))) {
33       if (id.equals(((IdObject)aObject).id)) {
34         result = true;
35       } // if
36
} // if
37

38     return result;
39   } // equals
40

41   public int hashCode() {
42     return id.hashCode();
43   } // hashCode
44
} // class IdObject
45

46
Popular Tags