KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > rice > rubis > beans > UserPK


1 package edu.rice.rubis.beans;
2
3 /**
4  * User Primary Key class
5  * @author <a HREF="mailto:cecchet@rice.edu">Emmanuel Cecchet</a> and <a HREF="mailto:julie.marguerite@inrialpes.fr">Julie Marguerite</a>
6  * @version 1.0
7  */

8 public class UserPK implements java.io.Serializable JavaDoc {
9
10   public Integer JavaDoc id;
11
12   /**
13    * Creates a new <code>UserPK</code> instance.
14    *
15    */

16   public UserPK() {}
17     
18   /**
19    * Creates a new <code>UserPK</code> instance.
20    *
21    * @param uniqueId an <code>Integer</code> value
22    */

23   public UserPK(Integer JavaDoc uniqueId)
24   {
25     id = uniqueId;
26   }
27
28   /**
29    * Specific <code>hashCode</code> just returning the id.
30    *
31    * @return the hash code
32    */

33   public int hashCode()
34   {
35     if (id == null)
36       return 0;
37     else
38       return id.intValue();
39   }
40
41   /**
42    * Specific <code>equals</code> method.
43    *
44    * @param other the <code>Object</code> to compare with
45    * @return true if both objects have the same primary key
46    */

47   public boolean equals(Object JavaDoc other)
48   {
49     boolean isEqual = false;
50     if (other instanceof UserPK)
51     {
52       if (id == null)
53         isEqual = (id == ((UserPK)other).id);
54       else
55         isEqual = (id.intValue() == ((UserPK)other).id.intValue());
56     }
57     return isEqual;
58   }
59   
60
61 }
62
Popular Tags