001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.xml.person;
023:
024: import org.jboss.xb.binding.SimpleTypeBindings;
025: import org.jboss.xb.binding.TypeBinding;
026:
027: import java.util.Collection;
028: import java.util.ArrayList;
029: import java.util.Arrays;
030:
031: /**
032: * @author <a href="mailto:alex@jboss.org">Alexey Loubyansky</a>
033: * @version <tt>$Revision: 57211 $</tt>
034: */
035: public class Person {
036: public static Person newInstance() {
037: Person person = new Person();
038: person.setFirstName("Vasiliy");
039: person.setLastName("Poupkin");
040: person
041: .setDateOfBirth((java.util.Date) SimpleTypeBindings.JAVA_UTIL_DATE
042: .unmarshal("1980-01-01"));
043: person.setPhones(Arrays.asList(new Object[] { "01", "02" }));
044:
045: ArrayList list = new ArrayList();
046: Address addr1 = new Address();
047: addr1.setStreet("prosp. Rad. Ukr. 11A, 70");
048: list.add(addr1);
049: addr1 = new Address();
050: addr1.setStreet("Sky 7");
051: list.add(addr1);
052: person.setAddresses(list);
053:
054: return person;
055: }
056:
057: private String firstName;
058: private String lastName;
059: private java.util.Date dateOfBirth;
060: private Collection phones = new ArrayList();
061: private Collection addresses = new ArrayList();
062:
063: public String getFirstName() {
064: return firstName;
065: }
066:
067: public void setFirstName(String firstName) {
068: this .firstName = firstName;
069: }
070:
071: public String getLastName() {
072: return lastName;
073: }
074:
075: public void setLastName(String lastName) {
076: this .lastName = lastName;
077: }
078:
079: public java.util.Date getDateOfBirth() {
080: return dateOfBirth;
081: }
082:
083: public void setDateOfBirth(java.util.Date dateOfBirth) {
084: this .dateOfBirth = dateOfBirth;
085: }
086:
087: public Collection getPhones() {
088: return phones;
089: }
090:
091: public void setPhones(Collection phones) {
092: this .phones = phones;
093: }
094:
095: public Collection getAddresses() {
096: return addresses;
097: }
098:
099: public void setAddresses(Collection addresses) {
100: this .addresses = addresses;
101: }
102:
103: public boolean equals(Object o) {
104: if (this == o)
105: return true;
106: if (!(o instanceof Person))
107: return false;
108:
109: final Person person = (Person) o;
110:
111: if (addresses != null ? !addresses.equals(person.addresses)
112: : person.addresses != null)
113: return false;
114: if (dateOfBirth != null ? !dateOfBirth
115: .equals(person.dateOfBirth)
116: : person.dateOfBirth != null)
117: return false;
118: if (firstName != null ? !firstName.equals(person.firstName)
119: : person.firstName != null)
120: return false;
121: if (lastName != null ? !lastName.equals(person.lastName)
122: : person.lastName != null)
123: return false;
124: if (phones != null ? !phones.equals(person.phones)
125: : person.phones != null)
126: return false;
127:
128: return true;
129: }
130:
131: public int hashCode() {
132: int result;
133: result = (firstName != null ? firstName.hashCode() : 0);
134: result = 29 * result
135: + (lastName != null ? lastName.hashCode() : 0);
136: result = 29 * result
137: + (dateOfBirth != null ? dateOfBirth.hashCode() : 0);
138: result = 29 * result + (phones != null ? phones.hashCode() : 0);
139: result = 29 * result
140: + (addresses != null ? addresses.hashCode() : 0);
141: return result;
142: }
143:
144: public String toString() {
145: return "[firstName=" + firstName + ", lastName=" + lastName
146: + ", dateOfBirth=" + dateOfBirth + ", phones=" + phones
147: + ", addresses=" + addresses + "]";
148: }
149: }
|