KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Data object for bank/Account.
26  */

27 public class AccountData extends java.lang.Object JavaDoc implements java.io.Serializable JavaDoc
28 {
29    /** The serialVersionUID */
30    private static final long serialVersionUID = -4437159401867282063L;
31
32    private java.lang.String JavaDoc id;
33
34    private java.lang.String JavaDoc customerId;
35
36    private int type;
37
38    private float balance;
39
40    public AccountData()
41    {
42    }
43
44    public AccountData(java.lang.String JavaDoc id, java.lang.String JavaDoc customerId, int type, float balance)
45    {
46       setId(id);
47       setCustomerId(customerId);
48       setType(type);
49       setBalance(balance);
50    }
51
52    public AccountData(AccountData otherData)
53    {
54       setId(otherData.getId());
55       setCustomerId(otherData.getCustomerId());
56       setType(otherData.getType());
57       setBalance(otherData.getBalance());
58
59    }
60
61    public org.jboss.test.banknew.interfaces.AccountPK getPrimaryKey()
62    {
63       org.jboss.test.banknew.interfaces.AccountPK pk = new org.jboss.test.banknew.interfaces.AccountPK(this.getId());
64       return pk;
65    }
66
67    public java.lang.String JavaDoc getId()
68    {
69       return this.id;
70    }
71
72    public void setId(java.lang.String JavaDoc id)
73    {
74       this.id = id;
75    }
76
77    public java.lang.String JavaDoc getCustomerId()
78    {
79       return this.customerId;
80    }
81
82    public void setCustomerId(java.lang.String JavaDoc customerId)
83    {
84       this.customerId = customerId;
85    }
86
87    public int getType()
88    {
89       return this.type;
90    }
91
92    public void setType(int type)
93    {
94       this.type = type;
95    }
96
97    public float getBalance()
98    {
99       return this.balance;
100    }
101
102    public void setBalance(float balance)
103    {
104       this.balance = balance;
105    }
106
107    public String JavaDoc toString()
108    {
109       StringBuffer JavaDoc str = new StringBuffer JavaDoc("{");
110
111       str.append("id=" + getId() + " " + "customerId=" + getCustomerId() + " " + "type=" + getType() + " " + "balance="
112             + getBalance());
113       str.append('}');
114
115       return (str.toString());
116    }
117
118    public boolean equals(Object JavaDoc pOther)
119    {
120       if (pOther instanceof AccountData)
121       {
122          AccountData lTest = (AccountData) pOther;
123          boolean lEquals = true;
124
125          if (this.id == null)
126          {
127             lEquals = lEquals && (lTest.id == null);
128          }
129          else
130          {
131             lEquals = lEquals && this.id.equals(lTest.id);
132          }
133          if (this.customerId == null)
134          {
135             lEquals = lEquals && (lTest.customerId == null);
136          }
137          else
138          {
139             lEquals = lEquals && this.customerId.equals(lTest.customerId);
140          }
141          lEquals = lEquals && this.type == lTest.type;
142          lEquals = lEquals && this.balance == lTest.balance;
143
144          return lEquals;
145       }
146       else
147       {
148          return false;
149       }
150    }
151
152    public int hashCode()
153    {
154       int result = 17;
155
156       result = 37 * result + ((this.id != null) ? this.id.hashCode() : 0);
157
158       result = 37 * result + ((this.customerId != null) ? this.customerId.hashCode() : 0);
159
160       result = 37 * result + type;
161
162       result = 37 * result + Float.floatToIntBits(balance);
163
164       return result;
165    }
166
167 }
168
Popular Tags