KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > interfaces > CustomerLightValue


1 /*
2  * Generated by XDoclet - Do not edit!
3  */

4 package test.interfaces;
5
6 /**
7  * Value object for Customer.
8  *
9  * Notice, this object is used to represent the state of an
10  * Customer object. This value object
11  * Is not connected to the database in any way, it is just a normal object used
12  * as a container for data from an EJB.
13  *
14  * @xdoclet-generated at 16-04-05
15  * @copyright The XDoclet Team
16  * @author XDoclet
17  * @version 1.2.3
18  */

19 public class CustomerLightValue
20    extends java.lang.Object JavaDoc
21    implements java.io.Serializable JavaDoc, java.lang.Cloneable JavaDoc
22 {
23
24    private float credit;
25    private boolean creditHasBeenSet = false;
26
27    private java.lang.String JavaDoc[][] array;
28    private boolean arrayHasBeenSet = false;
29
30    private byte[] image;
31    private boolean imageHasBeenSet = false;
32
33    private java.lang.String JavaDoc id;
34    private boolean idHasBeenSet = false;
35
36    private test.interfaces.CustomerPK primaryKey;
37
38    private int _version = 0;
39
40    public CustomerLightValue()
41    {
42       primaryKey = new test.interfaces.CustomerPK();
43    }
44
45    public CustomerLightValue( float credit,java.lang.String JavaDoc[][] array,byte[] image,java.lang.String JavaDoc id )
46    {
47        setCredit(credit);
48        setArray(array);
49        setImage(image);
50        setId(id);
51        primaryKey = new test.interfaces.CustomerPK(this.getId());
52    }
53
54    /**
55     * @deprecated use {@link #clone}
56     */

57    public CustomerLightValue( CustomerLightValue otherValue )
58    {
59       this.credit = otherValue.credit;
60       creditHasBeenSet = true;
61       this.array = otherValue.array;
62       arrayHasBeenSet = true;
63       this.image = otherValue.image;
64       imageHasBeenSet = true;
65       this.id = otherValue.id;
66       idHasBeenSet = true;
67
68       primaryKey = new test.interfaces.CustomerPK(this.getId());
69    }
70
71    public test.interfaces.CustomerPK getPrimaryKey()
72    {
73       return primaryKey;
74    }
75
76    public void setPrimaryKey( test.interfaces.CustomerPK primaryKey)
77    {
78       // it's also nice to update PK object - just in case
79
// somebody would ask for it later...
80
this.primaryKey = primaryKey;
81       setId( primaryKey.id );
82    }
83
84    public float getCredit()
85    {
86       return this.credit;
87    }
88
89    public void setCredit( float credit )
90    {
91       this.credit = credit;
92       creditHasBeenSet = true;
93
94    }
95
96    public boolean creditHasBeenSet(){
97       return creditHasBeenSet;
98    }
99    public java.lang.String JavaDoc[][] getArray()
100    {
101       return this.array;
102    }
103
104    private void setArray( java.lang.String JavaDoc[][] array )
105    {
106       this.array = array;
107       arrayHasBeenSet = true;
108
109    }
110
111    public byte[] getImage()
112    {
113       return this.image;
114    }
115
116    private void setImage( byte[] image )
117    {
118       this.image = image;
119       imageHasBeenSet = true;
120
121    }
122
123    public java.lang.String JavaDoc getId()
124    {
125       return this.id;
126    }
127
128    public void setId( java.lang.String JavaDoc id )
129    {
130       this.id = id;
131       idHasBeenSet = true;
132
133       primaryKey.setId(id);
134    }
135
136    public boolean idHasBeenSet(){
137       return idHasBeenSet;
138    }
139
140    public int getVersion()
141    {
142       return _version;
143    }
144    public void setVersion(int version)
145    {
146       this._version = version;
147    }
148
149    public String JavaDoc toString()
150    {
151       StringBuffer JavaDoc str = new StringBuffer JavaDoc("{");
152
153       str.append("credit=" + getCredit() + " " + "array=" + getArray() + " " + "image=" + getImage() + " " + "id=" + getId());
154       str.append(",version=");
155       str.append(_version);
156       str.append('}');
157
158       return(str.toString());
159    }
160
161    /**
162     * A Value Object has an identity if the attributes making its Primary Key have all been set. An object without identity is never equal to any other object.
163     *
164     * @return true if this instance has an identity.
165     */

166    protected boolean hasIdentity()
167    {
168       boolean ret = true;
169       ret = ret && idHasBeenSet;
170       return ret;
171    }
172
173    /**
174     *
175     * @deprecated use {@link #equals}
176     */

177    public boolean isIdentical(Object JavaDoc other)
178    {
179           if (other instanceof CustomerLightValue)
180           {
181                  CustomerLightValue that = (CustomerLightValue) other;
182                  boolean lEquals = true;
183                  lEquals = lEquals && this.credit == that.credit;
184                  if( this.array == null )
185                  {
186                         lEquals = lEquals && ( that.array == null );
187                  }
188                  else
189                  {
190                         lEquals = lEquals && this.array.equals( that.array );
191                  }
192                  lEquals = lEquals && this.image == that.image;
193
194                  return lEquals;
195           }
196           else
197           {
198                  return false;
199           }
200    }
201
202     public boolean equals(Object JavaDoc other) {
203
204         //If it's not the correct type, clearly it isn't equal to this.
205
if (!(other instanceof CustomerLightValue)) {
206             return false;
207         }
208
209         return equals((CustomerLightValue) other);
210     }
211
212     /**
213      * This class is not using strict ordering. This means that the object is not Comparable, and
214      * each check for equality will test all members for equality. We do not check collections for
215      * equality however, so you would be wise to not use this if you have collection typed EJB References.
216      */

217     public boolean equals(CustomerLightValue that) {
218
219         //try to get lucky.
220
if (this == that) {
221             return true;
222         }
223         //this clearly isn't null.
224
if(null == that) {
225             return false;
226         }
227
228         if(this.credit != that.credit) {
229             return false;
230         }
231
232         if(this.array != that.array) {
233
234             if( this.array == null || that.array == null ) {
235                 return false;
236             }
237
238             if(!this.array.equals(that.array)) {
239                 return false;
240             }
241
242         }
243
244         if(!java.util.Arrays.equals(this.image, that.image)) {
245             return false;
246         }
247
248         if(this.id != that.id) {
249
250             if( this.id == null || that.id == null ) {
251                 return false;
252             }
253
254             if(!this.id.equals(that.id)) {
255                 return false;
256             }
257
258         }
259
260         return true;
261
262     }
263
264     public Object JavaDoc clone() throws java.lang.CloneNotSupportedException JavaDoc {
265         CustomerLightValue other = (CustomerLightValue) super.clone();
266
267         return other;
268     }
269
270     public ReadOnlyCustomerLightValue getReadOnlyCustomerLightValue() {
271         return new ReadOnlyCustomerLightValue();
272     }
273
274     public int hashCode(){
275       int result = 17;
276       result = 37*result + Float.floatToIntBits(credit);
277
278       result = 37*result + ((this.array != null) ? this.array.hashCode() : 0);
279
280       if (image != null) {
281         for (int i=0; i<image.length; i++)
282         {
283           long l = image[i];
284           result = 37*result + (int)(l^(l>>>32));
285         }
286       }
287
288       result = 37*result + ((this.id != null) ? this.id.hashCode() : 0);
289
290       return result;
291     }
292
293     /**
294      * Covariant function so the compiler can choose the proper one at compile time,
295      * eliminates the need for XDoclet to really understand compiletime typing.
296      *
297      * Read only collections need to be synchronized. Once we start giving out handles
298      * to these collections, they'll be used in other threads sooner or later.
299      */

300     private static java.util.Collection JavaDoc wrapCollection(java.util.Collection JavaDoc input) {
301         return java.util.Collections.synchronizedCollection(input);
302     }
303     /**
304      * Covariant function so the compiler can choose the proper one at compile time,
305      * eliminates the need for XDoclet to really understand compiletime typing.
306      *
307      * Read only collections need to be synchronized. Once we start giving out handles
308      * to these collections, they'll be used in other threads sooner or later.
309      */

310     private static java.util.Set JavaDoc wrapCollection(java.util.Set JavaDoc input) {
311         return java.util.Collections.synchronizedSet(input);
312     }
313     /**
314      * Covariant function. This is used in covariant form so that the compiler
315      * can do some of our conditional branches for us. If I made these functions
316      * have different names, then XDoclet would have to choose between them based on
317      * compiletime types, that wouldn't be easy.
318      */

319     private static java.util.Collection JavaDoc wrapReadOnly(java.util.Collection JavaDoc input) {
320         return java.util.Collections.unmodifiableCollection(input);
321     }
322     /**
323      * Covariant function. This is used in covariant form so that the compiler
324      * can do some of our conditional branches for us. If I made these functions
325      * have different names, then XDoclet would have to choose between them based on
326      * compiletime types, that wouldn't be easy.
327      */

328     private static java.util.Set JavaDoc wrapReadOnly(java.util.Set JavaDoc input) {
329         return java.util.Collections.unmodifiableSet(input);
330     }
331
332     private final class ReadOnlyCustomerLightValue
333     implements java.lang.Cloneable JavaDoc, java.io.Serializable JavaDoc
334     {
335         private CustomerLightValue underlying() {
336             return CustomerLightValue.this;
337         }
338
339        public float getCredit() {
340               return underlying().credit;
341        }
342
343        public java.lang.String JavaDoc[][] getArray() {
344               return underlying().array;
345        }
346
347        public byte[] getImage() {
348               return underlying().image;
349        }
350
351        public java.lang.String JavaDoc getId() {
352               return underlying().id;
353        }
354
355         public int hashCode() {
356             return 101 * underlying().hashCode();
357         }
358
359         public boolean equals(Object JavaDoc o) {
360             if(o instanceof ReadOnlyCustomerLightValue) {
361                 return this.equals((ReadOnlyCustomerLightValue) o);
362             }
363             return false;
364         }
365
366         public boolean equals(ReadOnlyCustomerLightValue that) {
367             if(null == that) {
368                 return false;
369             }
370
371             return this.underlying().equals(that.underlying());
372         }
373
374     }
375
376 }
377
Popular Tags