1 package org.objectweb.rentacar.persistance.bo; 2 3 import org.apache.commons.lang.builder.CompareToBuilder; 4 import org.apache.commons.lang.builder.EqualsBuilder; 5 import org.apache.commons.lang.builder.HashCodeBuilder; 6 import org.apache.commons.lang.builder.ToStringBuilder; 7 8 13 public class AddressVO implements Comparable { 14 15 private String addressId; 16 17 private String address; 18 19 private String city; 20 21 private String zip; 22 23 private String country; 24 25 public AddressVO() { 26 super(); 27 } 28 29 36 public AddressVO(String address, String city, String zip, String country) { 37 super(); 38 this.address = address; 39 this.city = city; 40 this.zip = zip; 41 this.country = country; 42 } 43 44 52 public AddressVO(String addressId, String address, String city, String zip, String country) { 53 super(); 54 this.addressId = addressId; 55 this.address = address; 56 this.city = city; 57 this.zip = zip; 58 this.country = country; 59 } 60 61 65 public AddressVO(Address address) { 66 super(); 67 this.addressId = address.getAddressId(); 68 this.address = address.getAddress(); 69 this.city = address.getCity(); 70 this.zip = address.getZip(); 71 this.country = address.getCountry(); 72 } 73 74 public String getAddress() { 75 return address; 76 } 77 78 public void setAddress(String address) { 79 this.address = address; 80 } 81 82 85 public String getAddressId() { 86 return addressId; 87 } 88 89 public void setAddressId(String addressId) { 90 this.addressId = addressId; 91 } 92 93 public String getCity() { 94 return city; 95 } 96 97 public void setCity(String city) { 98 this.city = city; 99 } 100 101 public String getCountry() { 102 return country; 103 } 104 105 public void setCountry(String country) { 106 this.country = country; 107 } 108 109 public String getZip() { 110 return zip; 111 } 112 113 public void setZip(String zip) { 114 this.zip = zip; 115 } 116 117 120 public String toString() { 121 return new ToStringBuilder(this).append("country", this.country) 122 .append("address", this.address).append("addressId", 123 this.addressId).append("zip", this.zip).append("city", 124 this.city).toString(); 125 } 126 127 130 public boolean equals(Object object) { 131 if (!(object instanceof AddressVO)) { 132 return false; 133 } 134 AddressVO rhs = (AddressVO) object; 135 return new EqualsBuilder().append(this.addressId, rhs.addressId) 136 .append(this.country, rhs.country).append(this.address, 137 rhs.address).append(this.zip, rhs.zip).append( 138 this.city, rhs.city).isEquals(); 139 } 140 141 144 public int hashCode() { 145 return new HashCodeBuilder(-1574159667, 218892883).append( 146 this.addressId).append(this.country).append(this.address) 147 .append(this.zip).append(this.city).toHashCode(); 148 } 149 150 153 public int compareTo(Object object) { 154 AddressVO myClass = (AddressVO) object; 155 return new CompareToBuilder().append(this.addressId, myClass.addressId) 156 .append(this.country, myClass.country).append(this.address, 157 myClass.address).append(this.zip, myClass.zip).append( 158 this.city, myClass.city).toComparison(); 159 } 160 161 162 163 } 164 | Popular Tags |