KickJava   Java API By Example, From Geeks To Geeks.

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


1 package edu.rice.rubis.beans;
2
3 /**
4  * Category 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 CategoryPK implements java.io.Serializable JavaDoc {
9   
10   public Integer JavaDoc id;
11
12   /**
13    * Creates a new <code>CategoryPK</code> instance.
14    *
15    */

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

23   public CategoryPK(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    * Specific <code>equals</code> method.
42    *
43    * @param other the <code>Object</code> to compare with
44    * @return true if both objects have the same primary key
45    */

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