KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > rentacar > persistance > bo > AddressVO


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 /**
9  *
10  * @author ofabre
11  *
12  */

13 public class AddressVO implements Comparable JavaDoc {
14     
15     private String JavaDoc addressId;
16     
17     private String JavaDoc address;
18     
19     private String JavaDoc city;
20     
21     private String JavaDoc zip;
22     
23     private String JavaDoc country;
24
25     public AddressVO() {
26         super();
27     }
28
29     /**
30      * Class contructor
31      * @param address The number of the street and the street of the address
32      * @param city The city of the address
33      * @param zip The zip code of the address
34      * @param country The country of the address
35      */

36     public AddressVO(String JavaDoc address, String JavaDoc city, String JavaDoc zip, String JavaDoc country) {
37         super();
38         this.address = address;
39         this.city = city;
40         this.zip = zip;
41         this.country = country;
42     }
43     
44     /**
45      * Class contructor
46      * @param addressId The Id of the address
47      * @param address The number of the street and the street of the address
48      * @param city The city of the address
49      * @param zip The zip code of the address
50      * @param country The country of the address
51      */

52     public AddressVO(String JavaDoc addressId, String JavaDoc address, String JavaDoc city, String JavaDoc zip, String JavaDoc 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     /**
62      * Creates an AddressVO object from an Address object
63      * @param address
64      */

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 JavaDoc getAddress() {
75         return address;
76     }
77
78     public void setAddress(String JavaDoc address) {
79         this.address = address;
80     }
81
82     /**
83      * @return
84      */

85     public String JavaDoc getAddressId() {
86         return addressId;
87     }
88
89     public void setAddressId(String JavaDoc addressId) {
90         this.addressId = addressId;
91     }
92
93     public String JavaDoc getCity() {
94         return city;
95     }
96
97     public void setCity(String JavaDoc city) {
98         this.city = city;
99     }
100
101     public String JavaDoc getCountry() {
102         return country;
103     }
104
105     public void setCountry(String JavaDoc country) {
106         this.country = country;
107     }
108
109     public String JavaDoc getZip() {
110         return zip;
111     }
112
113     public void setZip(String JavaDoc zip) {
114         this.zip = zip;
115     }
116
117     /**
118      * @see java.lang.Object#toString()
119      */

120     public String JavaDoc 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     /**
128      * @see java.lang.Object#equals(Object)
129      */

130     public boolean equals(Object JavaDoc 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     /**
142      * @see java.lang.Object#hashCode()
143      */

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     /**
151      * @see java.lang.Comparable#compareTo(Object)
152      */

153     public int compareTo(Object JavaDoc 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