KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > xml > person > Person


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.test.xml.person;
8
9 import org.jboss.xb.binding.TypeConverter;
10
11 import java.util.Collection JavaDoc;
12 import java.util.ArrayList JavaDoc;
13 import java.util.Arrays JavaDoc;
14
15 /**
16  * @author <a HREF="mailto:alex@jboss.org">Alexey Loubyansky</a>
17  * @version <tt>$Revision: 1.2.2.2 $</tt>
18  */

19 public class Person
20 {
21    public static Person newInstance()
22    {
23       Person person = new Person();
24       person.setFirstName("Vasiliy");
25       person.setLastName("Poupkin");
26       person.setDateOfBirth((java.util.Date JavaDoc)TypeConverter.JAVA_UTIL_DATE.unmarshal("1980-01-01"));
27       person.setPhones(Arrays.asList(new Object JavaDoc[]{"01", "02"}));
28
29       ArrayList JavaDoc list = new ArrayList JavaDoc();
30       Address addr1 = new Address();
31       addr1.setStreet("prosp. Rad. Ukr. 11A, 70");
32       list.add(addr1);
33       addr1 = new Address();
34       addr1.setStreet("Sky 7");
35       list.add(addr1);
36       person.setAddresses(list);
37
38       return person;
39    }
40
41    private String JavaDoc firstName;
42    private String JavaDoc lastName;
43    private java.util.Date JavaDoc dateOfBirth;
44    private Collection JavaDoc phones = new ArrayList JavaDoc();
45    private Collection JavaDoc addresses = new ArrayList JavaDoc();
46
47    public String JavaDoc getFirstName()
48    {
49       return firstName;
50    }
51
52    public void setFirstName(String JavaDoc firstName)
53    {
54       this.firstName = firstName;
55    }
56
57    public String JavaDoc getLastName()
58    {
59       return lastName;
60    }
61
62    public void setLastName(String JavaDoc lastName)
63    {
64       this.lastName = lastName;
65    }
66
67    public java.util.Date JavaDoc getDateOfBirth()
68    {
69       return dateOfBirth;
70    }
71
72    public void setDateOfBirth(java.util.Date JavaDoc dateOfBirth)
73    {
74       this.dateOfBirth = dateOfBirth;
75    }
76
77    public Collection JavaDoc getPhones()
78    {
79       return phones;
80    }
81
82    public void setPhones(Collection JavaDoc phones)
83    {
84       this.phones = phones;
85    }
86
87    public Collection JavaDoc getAddresses()
88    {
89       return addresses;
90    }
91
92    public void setAddresses(Collection JavaDoc addresses)
93    {
94       this.addresses = addresses;
95    }
96
97    public boolean equals(Object JavaDoc o)
98    {
99       if(this == o) return true;
100       if(!(o instanceof Person)) return false;
101
102       final Person person = (Person) o;
103
104       if(addresses != null ? !addresses.equals(person.addresses) : person.addresses != null) return false;
105       if(dateOfBirth != null ? !dateOfBirth.equals(person.dateOfBirth) : person.dateOfBirth != null) return false;
106       if(firstName != null ? !firstName.equals(person.firstName) : person.firstName != null) return false;
107       if(lastName != null ? !lastName.equals(person.lastName) : person.lastName != null) return false;
108       if(phones != null ? !phones.equals(person.phones) : person.phones != null) return false;
109
110       return true;
111    }
112
113    public int hashCode()
114    {
115       int result;
116       result = (firstName != null ? firstName.hashCode() : 0);
117       result = 29 * result + (lastName != null ? lastName.hashCode() : 0);
118       result = 29 * result + (dateOfBirth != null ? dateOfBirth.hashCode() : 0);
119       result = 29 * result + (phones != null ? phones.hashCode() : 0);
120       result = 29 * result + (addresses != null ? addresses.hashCode() : 0);
121       return result;
122    }
123
124    public String JavaDoc toString()
125    {
126       return "[firstName=" + firstName +
127          ", lastName=" + lastName +
128          ", dateOfBirth=" + dateOfBirth +
129          ", phones=" + phones +
130          ", addresses=" + addresses + "]";
131    }
132 }
133
Popular Tags