KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tutorial > composite > bean > CustomerPK


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.tutorial.composite.bean;
8
9 import javax.persistence.Embeddable;
10 import javax.persistence.Embeddable;
11
12 /**
13  * Comment
14  *
15  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
16  * @version $Revision: 1.3.6.4 $
17  */

18 @Embeddable
19 public class CustomerPK implements java.io.Serializable JavaDoc
20 {
21    private long id;
22    private String JavaDoc name;
23
24
25    public CustomerPK()
26    {
27    }
28
29    public CustomerPK(long id, String JavaDoc name)
30    {
31       this.id = id;
32       this.name = name;
33    }
34
35    public long getId()
36    {
37       return id;
38    }
39
40    public void setId(long id)
41    {
42       this.id = id;
43    }
44
45    public String JavaDoc getName()
46    {
47       return name;
48    }
49
50    public void setName(String JavaDoc name)
51    {
52       this.name = name;
53    }
54
55    public int hashCode()
56    {
57       return (int) id + name.hashCode();
58    }
59
60    public boolean equals(Object JavaDoc obj)
61    {
62       if (obj == this) return true;
63       if (!(obj instanceof CustomerPK)) return false;
64       if (obj == null) return false;
65       CustomerPK pk = (CustomerPK) obj;
66       return pk.id == id && pk.name.equals(name);
67    }
68 }
69
Popular Tags