1 7 package org.jboss.test.xml.person; 8 9 import org.jboss.xb.binding.TypeConverter; 10 11 import java.util.Collection ; 12 import java.util.ArrayList ; 13 import java.util.Arrays ; 14 15 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 )TypeConverter.JAVA_UTIL_DATE.unmarshal("1980-01-01")); 27 person.setPhones(Arrays.asList(new Object []{"01", "02"})); 28 29 ArrayList list = new ArrayList (); 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 firstName; 42 private String lastName; 43 private java.util.Date dateOfBirth; 44 private Collection phones = new ArrayList (); 45 private Collection addresses = new ArrayList (); 46 47 public String getFirstName() 48 { 49 return firstName; 50 } 51 52 public void setFirstName(String firstName) 53 { 54 this.firstName = firstName; 55 } 56 57 public String getLastName() 58 { 59 return lastName; 60 } 61 62 public void setLastName(String lastName) 63 { 64 this.lastName = lastName; 65 } 66 67 public java.util.Date getDateOfBirth() 68 { 69 return dateOfBirth; 70 } 71 72 public void setDateOfBirth(java.util.Date dateOfBirth) 73 { 74 this.dateOfBirth = dateOfBirth; 75 } 76 77 public Collection getPhones() 78 { 79 return phones; 80 } 81 82 public void setPhones(Collection phones) 83 { 84 this.phones = phones; 85 } 86 87 public Collection getAddresses() 88 { 89 return addresses; 90 } 91 92 public void setAddresses(Collection addresses) 93 { 94 this.addresses = addresses; 95 } 96 97 public boolean equals(Object 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 toString() 125 { 126 return "[firstName=" + firstName + 127 ", lastName=" + lastName + 128 ", dateOfBirth=" + dateOfBirth + 129 ", phones=" + phones + 130 ", addresses=" + addresses + "]"; 131 } 132 } 133 | Popular Tags |