01: package auction.model;
02:
03: import java.io.Serializable;
04:
05: /**
06: * The address of a User.
07: *
08: * An instance of this class is always associated with only
09: * one <tt>User</tt> and depends on that parent objects lifecycle,
10: * it is a component. Of course, other entity classes can also
11: * embed addresses.
12: *
13: * @see User
14: * @author Christian Bauer
15: */
16: public class Address implements Serializable {
17:
18: private String street;
19: private String zipcode;
20: private String city;
21:
22: /**
23: * No-arg constructor for JavaBean tools
24: */
25: public Address() {
26: }
27:
28: /**
29: * Full constructor
30: */
31: public Address(String street, String zipcode, String city) {
32: this .street = street;
33: this .zipcode = zipcode;
34: this .city = city;
35: }
36:
37: // ********************** Accessor Methods ********************** //
38:
39: public String getStreet() {
40: return street;
41: }
42:
43: public void setStreet(String street) {
44: this .street = street;
45: }
46:
47: public String getZipcode() {
48: return zipcode;
49: }
50:
51: public void setZipcode(String zipcode) {
52: this .zipcode = zipcode;
53: }
54:
55: public String getCity() {
56: return city;
57: }
58:
59: public void setCity(String city) {
60: this .city = city;
61: }
62:
63: // ********************** Common Methods ********************** //
64:
65: public boolean equals(Object o) {
66: if (this == o)
67: return true;
68: if (!(o instanceof Address))
69: return false;
70:
71: final Address address = (Address) o;
72:
73: if (!city.equals(address.city))
74: return false;
75: if (!street.equals(address.street))
76: return false;
77: if (!zipcode.equals(address.zipcode))
78: return false;
79:
80: return true;
81: }
82:
83: public int hashCode() {
84: int result;
85: result = street.hashCode();
86: result = 29 * result + zipcode.hashCode();
87: result = 29 * result + city.hashCode();
88: return result;
89: }
90:
91: public String toString() {
92: return "Street: '" + getStreet() + "', " + "Zipcode: '"
93: + getZipcode() + "', " + "City: '" + getCity() + "'";
94: }
95:
96: // ********************** Business Methods ********************** //
97:
98: }
|