KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > ejb > cmr > EmployeeValue


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

4 package test.ejb.cmr;
5
6 /**
7  * Value object for Employee.
8  *
9  * Notice, this object is used to represent the state of an
10  * Employee 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 EmployeeValue
20    extends java.lang.Object JavaDoc
21    implements java.io.Serializable JavaDoc, java.lang.Cloneable JavaDoc
22 {
23
24    private java.lang.Integer JavaDoc id;
25    private boolean idHasBeenSet = false;
26
27    private java.lang.String JavaDoc name;
28    private boolean nameHasBeenSet = false;
29    private test.ejb.cmr.EmployeeAddressValue HomeAddress;
30    private boolean HomeAddressHasBeenSet = false;
31    private test.ejb.cmr.EmployeeAddressValue WorkAddress;
32    private boolean WorkAddressHasBeenSet = false;
33
34    private java.lang.Integer JavaDoc primaryKey;
35
36    public EmployeeValue()
37    {
38    }
39
40    public EmployeeValue( java.lang.Integer JavaDoc id,java.lang.String JavaDoc name )
41    {
42        setId(id);
43        setName(name);
44        primaryKey = this.getId();
45    }
46
47    /**
48     * @deprecated use {@link #clone}
49     */

50    public EmployeeValue( EmployeeValue otherValue )
51    {
52       this.id = otherValue.id;
53       idHasBeenSet = true;
54       this.name = otherValue.name;
55       nameHasBeenSet = true;
56       this.HomeAddress = otherValue.HomeAddress;
57       HomeAddressHasBeenSet = true;
58       this.WorkAddress = otherValue.WorkAddress;
59       WorkAddressHasBeenSet = true;
60
61       primaryKey = this.getId();
62    }
63
64    public java.lang.Integer JavaDoc getPrimaryKey()
65    {
66       return primaryKey;
67    }
68
69    public void setPrimaryKey( java.lang.Integer JavaDoc primaryKey)
70    {
71       // it's also nice to update PK object - just in case
72
// somebody would ask for it later...
73
this.primaryKey = primaryKey;
74       setId( primaryKey );
75    }
76
77    public java.lang.Integer JavaDoc getId()
78    {
79       return this.id;
80    }
81
82    public void setId( java.lang.Integer JavaDoc id )
83    {
84       this.id = id;
85       idHasBeenSet = true;
86
87       primaryKey = id;
88    }
89
90    public boolean idHasBeenSet(){
91       return idHasBeenSet;
92    }
93    public java.lang.String JavaDoc getName()
94    {
95       return this.name;
96    }
97
98    public void setName( java.lang.String JavaDoc name )
99    {
100       this.name = name;
101       nameHasBeenSet = true;
102
103    }
104
105    public boolean nameHasBeenSet(){
106       return nameHasBeenSet;
107    }
108
109    public test.ejb.cmr.EmployeeAddressValue getHomeAddress()
110    {
111       return this.HomeAddress;
112    }
113    public void setHomeAddress( test.ejb.cmr.EmployeeAddressValue HomeAddress )
114    {
115       this.HomeAddress = HomeAddress;
116       HomeAddressHasBeenSet = true;
117    }
118    public boolean homeAddressHasBeenSet()
119    {
120       return HomeAddressHasBeenSet;
121    }
122    public test.ejb.cmr.EmployeeAddressValue getWorkAddress()
123    {
124       return this.WorkAddress;
125    }
126    public void setWorkAddress( test.ejb.cmr.EmployeeAddressValue WorkAddress )
127    {
128       this.WorkAddress = WorkAddress;
129       WorkAddressHasBeenSet = true;
130    }
131    public boolean workAddressHasBeenSet()
132    {
133       return WorkAddressHasBeenSet;
134    }
135
136    public String JavaDoc toString()
137    {
138       StringBuffer JavaDoc str = new StringBuffer JavaDoc("{");
139
140       str.append("id=" + getId() + " " + "name=" + getName());
141       str.append('}');
142
143       return(str.toString());
144    }
145
146    /**
147     * 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.
148     *
149     * @return true if this instance has an identity.
150     */

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

160    public boolean isIdentical(Object JavaDoc other)
161    {
162           if (other instanceof EmployeeValue)
163           {
164                  EmployeeValue that = (EmployeeValue) other;
165                  boolean lEquals = true;
166                  if( this.id == null )
167                  {
168                         lEquals = lEquals && ( that.id == null );
169                  }
170                  else
171                  {
172                         lEquals = lEquals && this.id.equals( that.id );
173                  }
174                  if( this.name == null )
175                  {
176                         lEquals = lEquals && ( that.name == null );
177                  }
178                  else
179                  {
180                         lEquals = lEquals && this.name.equals( that.name );
181                  }
182                  if( this.HomeAddress == null )
183                  {
184                         lEquals = lEquals && ( that.HomeAddress == null );
185                  }
186                  else
187                  {
188                         lEquals = lEquals && this.HomeAddress.equals( that.HomeAddress );
189                  }
190                  if( this.WorkAddress == null )
191                  {
192                         lEquals = lEquals && ( that.WorkAddress == null );
193                  }
194                  else
195                  {
196                         lEquals = lEquals && this.WorkAddress.equals( that.WorkAddress );
197                  }
198
199                  return lEquals;
200           }
201           else
202           {
203                  return false;
204           }
205    }
206
207     public boolean equals(Object JavaDoc other) {
208
209         //If it's not the correct type, clearly it isn't equal to this.
210
if (!(other instanceof EmployeeValue)) {
211             return false;
212         }
213
214         return equals((EmployeeValue) other);
215     }
216
217     /**
218      * This class is not using strict ordering. This means that the object is not Comparable, and
219      * each check for equality will test all members for equality. We do not check collections for
220      * equality however, so you would be wise to not use this if you have collection typed EJB References.
221      */

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

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

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

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

336     private static java.util.Set JavaDoc wrapReadOnly(java.util.Set JavaDoc input) {
337         return java.util.Collections.unmodifiableSet(input);
338     }
339
340     private final class ReadOnlyEmployeeValue
341     implements java.lang.Cloneable JavaDoc, java.io.Serializable JavaDoc
342     {
343         private EmployeeValue underlying() {
344             return EmployeeValue.this;
345         }
346
347        public java.lang.Integer JavaDoc getId() {
348               return underlying().id;
349        }
350
351        public java.lang.String JavaDoc getName() {
352               return underlying().name;
353        }
354
355        public test.ejb.cmr.EmployeeAddressValue getHomeAddress()
356        {
357               return underlying().HomeAddress;
358        }
359        public test.ejb.cmr.EmployeeAddressValue getWorkAddress()
360        {
361               return underlying().WorkAddress;
362        }
363
364         public int hashCode() {
365             return 101 * underlying().hashCode();
366         }
367
368         public boolean equals(Object JavaDoc o) {
369             if(o instanceof ReadOnlyEmployeeValue) {
370                 return this.equals((ReadOnlyEmployeeValue) o);
371             }
372             return false;
373         }
374
375         public boolean equals(ReadOnlyEmployeeValue that) {
376             if(null == that) {
377                 return false;
378             }
379
380             return this.underlying().equals(that.underlying());
381         }
382
383     }
384
385 }
386
Popular Tags