1 package org.objectweb.rentacar.persistance.bo; 2 3 import javax.persistence.Entity; 4 import javax.persistence.GeneratedValue; 5 import javax.persistence.Id; 6 7 import org.hibernate.annotations.GenericGenerator; 8 import org.apache.commons.lang.builder.EqualsBuilder; 9 import org.apache.commons.lang.builder.HashCodeBuilder; 10 import org.apache.commons.lang.builder.ToStringBuilder; 11 import org.apache.commons.lang.builder.CompareToBuilder; 12 13 18 @Entity 19 public class Address implements Comparable { 20 21 private String addressId; 22 23 private String address; 24 25 private String city; 26 27 private String zip; 28 29 private String country; 30 31 32 public Address() { 33 super(); 34 } 35 36 43 public Address(String address, String city, String zip, String country) { 44 super(); 45 this.address = address; 46 this.city = city; 47 this.zip = zip; 48 this.country = country; 49 } 50 51 59 public Address(String addressId, String address, String city, String zip, String country) { 60 super(); 61 this.addressId = addressId; 62 this.address = address; 63 this.city = city; 64 this.zip = zip; 65 this.country = country; 66 } 67 68 72 public Address(AddressVO addressVO){ 73 super(); 74 this.addressId = addressVO.getAddressId(); 75 this.address = addressVO.getAddress(); 76 this.city = addressVO.getCity(); 77 this.zip = addressVO.getZip(); 78 this.country = addressVO.getCountry(); 79 } 80 81 public String getAddress() { 82 return address; 83 } 84 85 public void setAddress(String address) { 86 this.address = address; 87 } 88 89 @Id @GeneratedValue(generator = "system-uuid") 90 @GenericGenerator(name="system-uuid", strategy = "uuid") 91 public String getAddressId() { 92 return addressId; 93 } 94 95 public void setAddressId(String addressId) { 96 this.addressId = addressId; 97 } 98 99 public String getCity() { 100 return city; 101 } 102 103 public void setCity(String city) { 104 this.city = city; 105 } 106 107 public String getCountry() { 108 return country; 109 } 110 111 public void setCountry(String country) { 112 this.country = country; 113 } 114 115 public String getZip() { 116 return zip; 117 } 118 119 public void setZip(String zip) { 120 this.zip = zip; 121 } 122 123 126 public String toString() { 127 return new ToStringBuilder(this).append("country", this.country) 128 .append("address", this.address).append("addressId", 129 this.addressId).append("zip", this.zip).append("city", 130 this.city).toString(); 131 } 132 133 136 public boolean equals(Object object) { 137 if (!(object instanceof Address)) { 138 return false; 139 } 140 Address rhs = (Address) object; 141 return new EqualsBuilder().append(this.addressId, rhs.addressId) 142 .append(this.country, rhs.country).append(this.address, 143 rhs.address).append(this.zip, rhs.zip).append( 144 this.city, rhs.city).isEquals(); 145 } 146 147 150 public int hashCode() { 151 return new HashCodeBuilder(-1574159667, 218892883).append( 152 this.addressId).append(this.country).append(this.address) 153 .append(this.zip).append(this.city).toHashCode(); 154 } 155 156 159 public int compareTo(Object object) { 160 Address myClass = (Address) object; 161 return new CompareToBuilder().append(this.addressId, myClass.addressId) 162 .append(this.country, myClass.country).append(this.address, 163 myClass.address).append(this.zip, myClass.zip).append( 164 this.city, myClass.city).toComparison(); 165 } 166 167 168 169 } 170 | Popular Tags |