KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > interfaces > AddressValue


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

4 package test.interfaces;
5
6 /**
7  * Value object for Address.
8  *
9  * Notice, this object is used to represent the state of an
10  * Address 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 AddressValue
20    extends java.lang.Object JavaDoc
21    implements java.io.Serializable JavaDoc, java.lang.Cloneable JavaDoc
22 {
23
24    private java.lang.String JavaDoc id;
25    private boolean idHasBeenSet = false;
26
27    private java.lang.String JavaDoc street;
28    private boolean streetHasBeenSet = false;
29
30    private java.lang.String JavaDoc city;
31    private boolean cityHasBeenSet = false;
32
33    private int readOnly;
34    private boolean readOnlyHasBeenSet = false;
35
36    private java.lang.String JavaDoc primaryKey;
37
38    public AddressValue()
39    {
40    }
41
42    public AddressValue( java.lang.String JavaDoc id,java.lang.String JavaDoc street,java.lang.String JavaDoc city,int readOnly )
43    {
44        setId(id);
45        setStreet(street);
46        setCity(city);
47        setReadOnly(readOnly);
48        primaryKey = this.getId();
49    }
50
51    /**
52     * @deprecated use {@link #clone}
53     */

54    public AddressValue( AddressValue otherValue )
55    {
56       this.id = otherValue.id;
57       idHasBeenSet = true;
58       this.street = otherValue.street;
59       streetHasBeenSet = true;
60       this.city = otherValue.city;
61       cityHasBeenSet = true;
62       this.readOnly = otherValue.readOnly;
63       readOnlyHasBeenSet = true;
64
65       primaryKey = this.getId();
66    }
67
68    public java.lang.String JavaDoc getPrimaryKey()
69    {
70       return primaryKey;
71    }
72
73    public void setPrimaryKey( java.lang.String JavaDoc primaryKey)
74    {
75       // it's also nice to update PK object - just in case
76
// somebody would ask for it later...
77
this.primaryKey = primaryKey;
78       setId( primaryKey );
79    }
80
81    public java.lang.String JavaDoc getId()
82    {
83       return this.id;
84    }
85
86    public void setId( java.lang.String JavaDoc id )
87    {
88       this.id = id;
89       idHasBeenSet = true;
90
91       primaryKey = id;
92    }
93
94    public boolean idHasBeenSet(){
95       return idHasBeenSet;
96    }
97    public java.lang.String JavaDoc getStreet()
98    {
99       return this.street;
100    }
101
102    private void setStreet( java.lang.String JavaDoc street )
103    {
104       this.street = street;
105       streetHasBeenSet = true;
106
107    }
108
109    public java.lang.String JavaDoc getCity()
110    {
111       return this.city;
112    }
113
114    private void setCity( java.lang.String JavaDoc city )
115    {
116       this.city = city;
117       cityHasBeenSet = true;
118
119    }
120
121    public int getReadOnly()
122    {
123       return this.readOnly;
124    }
125
126    private void setReadOnly( int readOnly )
127    {
128       this.readOnly = readOnly;
129       readOnlyHasBeenSet = true;
130
131    }
132
133    public String JavaDoc toString()
134    {
135       StringBuffer JavaDoc str = new StringBuffer JavaDoc("{");
136
137       str.append("id=" + getId() + " " + "street=" + getStreet() + " " + "city=" + getCity() + " " + "readOnly=" + getReadOnly());
138       str.append('}');
139
140       return(str.toString());
141    }
142
143    /**
144     * 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.
145     *
146     * @return true if this instance has an identity.
147     */

148    protected boolean hasIdentity()
149    {
150       return idHasBeenSet;
151    }
152
153    /**
154     *
155     * @deprecated use {@link #equals}
156     */

157    public boolean isIdentical(Object JavaDoc other)
158    {
159           if (other instanceof AddressValue)
160           {
161                  AddressValue that = (AddressValue) other;
162                  boolean lEquals = true;
163                  if( this.street == null )
164                  {
165                         lEquals = lEquals && ( that.street == null );
166                  }
167                  else
168                  {
169                         lEquals = lEquals && this.street.equals( that.street );
170                  }
171                  if( this.city == null )
172                  {
173                         lEquals = lEquals && ( that.city == null );
174                  }
175                  else
176                  {
177                         lEquals = lEquals && this.city.equals( that.city );
178                  }
179                  lEquals = lEquals && this.readOnly == that.readOnly;
180
181                  return lEquals;
182           }
183           else
184           {
185                  return false;
186           }
187    }
188
189     public boolean equals(Object JavaDoc other) {
190
191         //If it's not the correct type, clearly it isn't equal to this.
192
if (!(other instanceof AddressValue)) {
193             return false;
194         }
195
196         return equals((AddressValue) other);
197     }
198
199     /**
200      * This class is not using strict ordering. This means that the object is not Comparable, and
201      * each check for equality will test all members for equality. We do not check collections for
202      * equality however, so you would be wise to not use this if you have collection typed EJB References.
203      */

204     public boolean equals(AddressValue that) {
205
206         //try to get lucky.
207
if (this == that) {
208             return true;
209         }
210         //this clearly isn't null.
211
if(null == that) {
212             return false;
213         }
214
215         if(this.id != that.id) {
216
217             if( this.id == null || that.id == null ) {
218                 return false;
219             }
220
221             if(!this.id.equals(that.id)) {
222                 return false;
223             }
224
225         }
226
227         if(this.street != that.street) {
228
229             if( this.street == null || that.street == null ) {
230                 return false;
231             }
232
233             if(!this.street.equals(that.street)) {
234                 return false;
235             }
236
237         }
238
239         if(this.city != that.city) {
240
241             if( this.city == null || that.city == null ) {
242                 return false;
243             }
244
245             if(!this.city.equals(that.city)) {
246                 return false;
247             }
248
249         }
250
251         if(this.readOnly != that.readOnly) {
252             return false;
253         }
254
255         return true;
256
257     }
258
259     public Object JavaDoc clone() throws java.lang.CloneNotSupportedException JavaDoc {
260         AddressValue other = (AddressValue) super.clone();
261
262         return other;
263     }
264
265     public ReadOnlyAddressValue getReadOnlyAddressValue() {
266         return new ReadOnlyAddressValue();
267     }
268
269     public int hashCode(){
270       int result = 17;
271       result = 37*result + ((this.id != null) ? this.id.hashCode() : 0);
272
273       result = 37*result + ((this.street != null) ? this.street.hashCode() : 0);
274
275       result = 37*result + ((this.city != null) ? this.city.hashCode() : 0);
276
277       result = 37*result + (int) readOnly;
278
279       return result;
280     }
281
282     /**
283      * Covariant function so the compiler can choose the proper one at compile time,
284      * eliminates the need for XDoclet to really understand compiletime typing.
285      *
286      * Read only collections need to be synchronized. Once we start giving out handles
287      * to these collections, they'll be used in other threads sooner or later.
288      */

289     private static java.util.Collection JavaDoc wrapCollection(java.util.Collection JavaDoc input) {
290         return java.util.Collections.synchronizedCollection(input);
291     }
292     /**
293      * Covariant function so the compiler can choose the proper one at compile time,
294      * eliminates the need for XDoclet to really understand compiletime typing.
295      *
296      * Read only collections need to be synchronized. Once we start giving out handles
297      * to these collections, they'll be used in other threads sooner or later.
298      */

299     private static java.util.Set JavaDoc wrapCollection(java.util.Set JavaDoc input) {
300         return java.util.Collections.synchronizedSet(input);
301     }
302     /**
303      * Covariant function. This is used in covariant form so that the compiler
304      * can do some of our conditional branches for us. If I made these functions
305      * have different names, then XDoclet would have to choose between them based on
306      * compiletime types, that wouldn't be easy.
307      */

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

317     private static java.util.Set JavaDoc wrapReadOnly(java.util.Set JavaDoc input) {
318         return java.util.Collections.unmodifiableSet(input);
319     }
320
321     private final class ReadOnlyAddressValue
322     implements java.lang.Cloneable JavaDoc, java.io.Serializable JavaDoc
323     {
324         private AddressValue underlying() {
325             return AddressValue.this;
326         }
327
328        public java.lang.String JavaDoc getId() {
329               return underlying().id;
330        }
331
332        public java.lang.String JavaDoc getStreet() {
333               return underlying().street;
334        }
335
336        public java.lang.String JavaDoc getCity() {
337               return underlying().city;
338        }
339
340        public int getReadOnly() {
341               return underlying().readOnly;
342        }
343
344         public int hashCode() {
345             return 101 * underlying().hashCode();
346         }
347
348         public boolean equals(Object JavaDoc o) {
349             if(o instanceof ReadOnlyAddressValue) {
350                 return this.equals((ReadOnlyAddressValue) o);
351             }
352             return false;
353         }
354
355         public boolean equals(ReadOnlyAddressValue that) {
356             if(null == that) {
357                 return false;
358             }
359
360             return this.underlying().equals(that.underlying());
361         }
362
363     }
364
365 }
366
Popular Tags