KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > banknew > interfaces > BankPK


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2006, 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.test.banknew.interfaces;
23
24 /**
25  * Primary key for bank/Bank.
26  */

27 public class BankPK extends java.lang.Object JavaDoc implements java.io.Serializable JavaDoc
28 {
29    /** The serialVersionUID */
30    private static final long serialVersionUID = 2608720469606729860L;
31
32    private int _hashCode = 0;
33
34    private StringBuffer JavaDoc _toStringValue = null;
35
36    public java.lang.String JavaDoc id;
37
38    public BankPK()
39    {
40    }
41
42    public BankPK(java.lang.String JavaDoc id)
43    {
44       this.id = id;
45    }
46
47    public java.lang.String JavaDoc getId()
48    {
49       return id;
50    }
51
52    public void setId(java.lang.String JavaDoc id)
53    {
54       this.id = id;
55       _hashCode = 0;
56    }
57
58    public int hashCode()
59    {
60       if (_hashCode == 0)
61       {
62          if (this.id != null)
63             _hashCode += this.id.hashCode();
64       }
65
66       return _hashCode;
67    }
68
69    public boolean equals(Object JavaDoc obj)
70    {
71       if (!(obj instanceof org.jboss.test.banknew.interfaces.BankPK))
72          return false;
73
74       org.jboss.test.banknew.interfaces.BankPK pk = (org.jboss.test.banknew.interfaces.BankPK) obj;
75       boolean eq = true;
76
77       if (obj == null)
78       {
79          eq = false;
80       }
81       else
82       {
83          if (this.id == null && ((org.jboss.test.banknew.interfaces.BankPK) obj).getId() == null)
84          {
85             eq = true;
86          }
87          else
88          {
89             if (this.id == null || ((org.jboss.test.banknew.interfaces.BankPK) obj).getId() == null)
90             {
91                eq = false;
92             }
93             else
94             {
95                eq = eq && this.id.equals(pk.id);
96             }
97          }
98       }
99
100       return eq;
101    }
102
103    /** @return String representation of this pk in the form of [.field1.field2.field3]. */
104    public String JavaDoc toString()
105    {
106       if (_toStringValue == null)
107       {
108          _toStringValue = new StringBuffer JavaDoc("[.");
109          _toStringValue.append(this.id).append('.');
110          _toStringValue.append(']');
111       }
112
113       return _toStringValue.toString();
114    }
115
116 }
117
Popular Tags