KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > composite > CustomerPK


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ejb3.test.composite;
23
24 import javax.persistence.Embeddable;
25
26 /**
27  * Comment
28  *
29  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
30  * @version $Revision: 37459 $
31  */

32 @Embeddable
33 public class CustomerPK implements java.io.Serializable JavaDoc
34 {
35    private long id;
36    private String JavaDoc name;
37
38
39    public CustomerPK()
40    {
41    }
42
43    public CustomerPK(long id, String JavaDoc name)
44    {
45       this.id = id;
46       this.name = name;
47    }
48
49    public long getId()
50    {
51       return id;
52    }
53
54    public void setId(long id)
55    {
56       this.id = id;
57    }
58
59    public String JavaDoc getName()
60    {
61       return name;
62    }
63
64    public void setName(String JavaDoc name)
65    {
66       this.name = name;
67    }
68
69    public int hashCode()
70    {
71       return (int) id + name.hashCode();
72    }
73
74    public boolean equals(Object JavaDoc obj)
75    {
76       if (obj == this) return true;
77       if (!(obj instanceof CustomerPK)) return false;
78       if (obj == null) return false;
79       CustomerPK pk = (CustomerPK) obj;
80       return pk.id == id && pk.name.equals(name);
81    }
82 }
83
Popular Tags