1 /***
2 Copyright (C) 2005 The Java Community
3
4 This program is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free Software
6 Foundation; either version 2 of the License, or (at your option) any later
7 version.
8
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 Place, Suite 330, Boston, MA 02111-1307 USA.
16
17 */
18 package org.bejug.javacareers.jobs.model;
19
20 import org.apache.commons.lang.builder.CompareToBuilder;
21 import org.apache.commons.lang.builder.EqualsBuilder;
22 import org.apache.commons.lang.builder.HashCodeBuilder;
23 import org.apache.commons.lang.builder.ToStringBuilder;
24
25
26
27 /***
28 *
29 * @author Bart Meyers (last modified by $Author: shally $)
30 * @version $Revision: 1.4 $ - $Date: 2005/12/20 15:36:45 $
31 */
32 public class Address extends AbstractPersistableObject {
33
34 /***
35 * name
36 */
37 private String name;
38
39 /***
40 * street
41 */
42 private String street;
43
44 /***
45 * number
46 */
47 private String number;
48
49 /***
50 * region
51 */
52 protected Region region;
53
54 /***
55 * city
56 */
57 protected String city;
58
59
60 /***
61 * zip code
62 */
63 protected String zipCode;
64
65 /***
66 * Country
67 */
68 protected String country;
69
70
71 /***
72 * @param name adres name
73 * @param street street name
74 * @param number house number
75 * @param city city
76 * @param zipCode zip code
77 * @param region region
78 */
79 public Address(String name, String street, String number, String city,
80 String zipCode, Region region) {
81 super();
82 this.name = name;
83 this.street = street;
84 this.number = number;
85 this.city = city;
86 this.zipCode = zipCode;
87 this.region = region;
88 }
89
90 /***
91 * default constructor
92 */
93 public Address() {
94 }
95
96 /***
97 *
98 * @return name String
99 */
100 public String getName() {
101 return name;
102 }
103
104 /***
105 *
106 * @param name String
107 */
108 public void setName(String name) {
109 this.name = name;
110 }
111
112 /***
113 *
114 * @return number String
115 */
116 public String getNumber() {
117 return number;
118 }
119
120 /***
121 *
122 * @param number String
123 */
124 public void setNumber(String number) {
125 this.number = number;
126 }
127
128 /***
129 *
130 * @return street String
131 */
132 public String getStreet() {
133 return street;
134 }
135
136 /***
137 *
138 * @param street String
139 */
140 public void setStreet(String street) {
141 this.street = street;
142 }
143
144 /***
145 *
146 * @return city String
147 */
148 public String getCity() {
149 return city;
150 }
151
152 /***
153 *
154 * @param city String
155 */
156 public void setCity(String city) {
157 this.city = city;
158 }
159
160 /***
161 *
162 * @return country String
163 */
164 public String getCountry() {
165 return region.getCountry().getName();
166 }
167
168 /***
169 *
170 * @param country String
171 */
172 public void setCountry(String country) {
173 this.country= country;
174 }
175
176
177 /***
178 *
179 * @return zip code String
180 */
181 public String getZipCode() {
182 return zipCode;
183 }
184
185 /***
186 *
187 * @param zipCode String
188 */
189 public void setZipCode(String zipCode) {
190 this.zipCode = zipCode;
191 }
192
193 /***
194 * @return Returns the region.
195 */
196 public Region getRegion() {
197 return region;
198 }
199
200 /***
201 * @param region The region to set.
202 */
203 public void setRegion(Region region) {
204 this.region = region;
205 }
206 /***
207 * @return Returns the region.
208 */
209 public String getRegionName() {
210 return region.getName();
211 }
212
213 /***
214 * {@inheritDoc}
215 */
216 public boolean equals(Object o) {
217 if (!(o instanceof Address)) {
218 return false;
219 }
220 if (this == o) {
221 return true;
222 }
223 Address address = (Address) o;
224 return new EqualsBuilder()
225 .appendSuper(super.equals(o))
226 .append(this.name, address.getName())
227 .append(this.street, address.getStreet())
228 .append(this.number, address.getNumber())
229 .append(this.region, address.getRegion())
230 .append(this.city, address.getCity())
231 .append(this.zipCode, address.getZipCode())
232 .isEquals();
233 }
234
235
236 /***
237 * {@inheritDoc}
238 */
239 public int hashCode() {
240 return new HashCodeBuilder(67, 89)
241 .append(this.name)
242 .append(this.street)
243 .append(this.number)
244 .append(this.region)
245 .append(this.city)
246 .append(this.zipCode)
247 .toHashCode();
248 }
249
250
251 /***
252 * {@inheritDoc}
253 */
254 public int compareTo(Object o) {
255 Address address = (Address) o;
256 return new CompareToBuilder()
257 .appendSuper(super.compareTo(address))
258 .append(this.name, address.getName())
259 .append(this.street, address.getStreet())
260 .append(this.number, address.getNumber())
261 .append(this.region, address.getRegion())
262 .append(this.city, address.getCity())
263 .append(this.zipCode, address.getZipCode())
264 .toComparison();
265 }
266
267
268 /***
269 * {@inheritDoc}
270 */
271 public String toString() {
272 return new ToStringBuilder(this)
273 .appendSuper(super.toString())
274 .append("name", this.name)
275 .append("street", this.street)
276 .append("number", this.number)
277 .append("region", this.region)
278 .append("city", this.city)
279 .append("zipCode", this.zipCode)
280 .toString();
281 }
282
283 }
284 /***
285 * $Log: Address.java,v $
286 * Revision 1.4 2005/12/20 15:36:45 shally
287 * CheckStyle and PMD changes.
288 *
289 * Revision 1.3 2005/09/05 16:23:31 schauwvliege
290 * Country property should be deleted
291 *
292 * Revision 1.2 2005/08/31 12:15:09 bme_jcs
293 * refactoring and introduction of apache builders
294 *
295 * Revision 1.1 2005/08/26 07:58:26 ge0ffrey
296 * split up the sources in service, serviceimpl and webclient
297 *
298 * Revision 1.5 2005/08/08 09:38:21 bme_jcs
299 * resolved checkstyle errors
300 *
301 * Revision 1.4 2005/07/25 15:12:40 psong09
302 * cleaned up and debugged signup and update profile functionality
303 *
304 * Revision 1.3 2005/07/05 15:13:11 schauwvliege
305 * added person/contact and location to model
306 *
307 * Revision 1.2 2005/06/09 08:18:52 bejug_cc
308 * Fix initial import
309 *
310 * Revision 1.6 2005/05/09 13:42:10 ssc
311 * checkstyle
312 *
313 * Revision 1.5 2005/04/29 18:17:34 sja
314 * General cleanup (naming conv., javadoc and CVS tags)
315 *
316 * Revision 1.4 2005/04/29 07:01:47 PSONG09
317 * update
318 * Revision 1.3 2005/04/25 16:03:40 ssc added constructor
319 *
320 * Revision 1.2 2005/04/23 14:29:27 sja Added CVS tag
321 *
322 */