KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Object to test non-primitive key.
11  */

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

24    public ValueObject(IdObject aIdObj, float aValue)
25    {
26       idObj = aIdObj;
27       value = aValue;
28    } // ValueObject
29

30    public IdObject getIdObj()
31    {
32       return idObj;
33    }
34
35    public float getValue()
36    {
37       return value;
38    }
39
40    public String JavaDoc toString()
41    {
42       return idObj + ": " + value;
43    } // toString
44

45    public boolean equals(Object JavaDoc aObject)
46    {
47       boolean result = false;
48
49       if ((aObject != null) &&
50               (aObject.getClass().getName().equals(this.getClass().getName())))
51       {
52          result = idObj.equals(((ValueObject) aObject).idObj);
53       } // if
54

55       return result;
56    } // equals
57

58    public int hashCode()
59    {
60       return idObj.hashCode();
61    } // hashCode
62
} // class ValueObject
63
Popular Tags