KickJava   Java API By Example, From Geeks To Geeks.

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


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/Transaction.
26  */

27 public class TransactionData extends java.lang.Object JavaDoc implements java.io.Serializable JavaDoc
28 {
29    /** The serialVersionUID */
30    private static final long serialVersionUID = 8601981534267975114L;
31
32    private java.lang.String JavaDoc id;
33
34    private java.lang.String JavaDoc acountId;
35
36    private int type;
37
38    private float amount;
39
40    private java.util.Date JavaDoc date;
41
42    private java.lang.String JavaDoc description;
43
44    public TransactionData()
45    {
46    }
47
48    public TransactionData(java.lang.String JavaDoc id, java.lang.String JavaDoc acountId, int type, float amount, java.util.Date JavaDoc date,
49          java.lang.String JavaDoc description)
50    {
51       setId(id);
52       setAcountId(acountId);
53       setType(type);
54       setAmount(amount);
55       setDate(date);
56       setDescription(description);
57    }
58
59    public TransactionData(TransactionData otherData)
60    {
61       setId(otherData.getId());
62       setAcountId(otherData.getAcountId());
63       setType(otherData.getType());
64       setAmount(otherData.getAmount());
65       setDate(otherData.getDate());
66       setDescription(otherData.getDescription());
67
68    }
69
70    public org.jboss.test.banknew.interfaces.TransactionPK getPrimaryKey()
71    {
72       org.jboss.test.banknew.interfaces.TransactionPK pk = new org.jboss.test.banknew.interfaces.TransactionPK(this
73             .getId());
74       return pk;
75    }
76
77    public java.lang.String JavaDoc getId()
78    {
79       return this.id;
80    }
81
82    public void setId(java.lang.String JavaDoc id)
83    {
84       this.id = id;
85    }
86
87    public java.lang.String JavaDoc getAcountId()
88    {
89       return this.acountId;
90    }
91
92    public void setAcountId(java.lang.String JavaDoc acountId)
93    {
94       this.acountId = acountId;
95    }
96
97    public int getType()
98    {
99       return this.type;
100    }
101
102    public void setType(int type)
103    {
104       this.type = type;
105    }
106
107    public float getAmount()
108    {
109       return this.amount;
110    }
111
112    public void setAmount(float amount)
113    {
114       this.amount = amount;
115    }
116
117    public java.util.Date JavaDoc getDate()
118    {
119       return this.date;
120    }
121
122    public void setDate(java.util.Date JavaDoc date)
123    {
124       this.date = date;
125    }
126
127    public java.lang.String JavaDoc getDescription()
128    {
129       return this.description;
130    }
131
132    public void setDescription(java.lang.String JavaDoc description)
133    {
134       this.description = description;
135    }
136
137    public String JavaDoc toString()
138    {
139       StringBuffer JavaDoc str = new StringBuffer JavaDoc("{");
140
141       str.append("id=" + getId() + " " + "acountId=" + getAcountId() + " " + "type=" + getType() + " " + "amount="
142             + getAmount() + " " + "date=" + getDate() + " " + "description=" + getDescription());
143       str.append('}');
144
145       return (str.toString());
146    }
147
148    public boolean equals(Object JavaDoc pOther)
149    {
150       if (pOther instanceof TransactionData)
151       {
152          TransactionData lTest = (TransactionData) pOther;
153          boolean lEquals = true;
154
155          if (this.id == null)
156          {
157             lEquals = lEquals && (lTest.id == null);
158          }
159          else
160          {
161             lEquals = lEquals && this.id.equals(lTest.id);
162          }
163          if (this.acountId == null)
164          {
165             lEquals = lEquals && (lTest.acountId == null);
166          }
167          else
168          {
169             lEquals = lEquals && this.acountId.equals(lTest.acountId);
170          }
171          lEquals = lEquals && this.type == lTest.type;
172          lEquals = lEquals && this.amount == lTest.amount;
173          if (this.date == null)
174          {
175             lEquals = lEquals && (lTest.date == null);
176          }
177          else
178          {
179             lEquals = lEquals && this.date.equals(lTest.date);
180          }
181          if (this.description == null)
182          {
183             lEquals = lEquals && (lTest.description == null);
184          }
185          else
186          {
187             lEquals = lEquals && this.description.equals(lTest.description);
188          }
189
190          return lEquals;
191       }
192       else
193       {
194          return false;
195       }
196    }
197
198    public int hashCode()
199    {
200       int result = 17;
201
202       result = 37 * result + ((this.id != null) ? this.id.hashCode() : 0);
203
204       result = 37 * result + ((this.acountId != null) ? this.acountId.hashCode() : 0);
205
206       result = 37 * result + type;
207
208       result = 37 * result + Float.floatToIntBits(amount);
209
210       result = 37 * result + ((this.date != null) ? this.date.hashCode() : 0);
211
212       result = 37 * result + ((this.description != null) ? this.description.hashCode() : 0);
213
214       return result;
215    }
216
217 }
218
Popular Tags