KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > appfuse > model > Address


1 package org.appfuse.model;
2
3 import java.io.Serializable JavaDoc;
4
5 import org.apache.commons.lang.builder.ToStringBuilder;
6 import org.apache.commons.lang.builder.ToStringStyle;
7
8 /**
9  * This class is used to represent an address.</p>
10  *
11  * <p><a HREF="Address.java.htm"><i>View Source</i></a></p>
12  *
13  * @author <a HREF="mailto:matt@raibledesigns.com">Matt Raible</a>
14  *
15  * @struts.form include-all="true" extends="BaseForm"
16  */

17 public class Address extends BaseObject implements Serializable JavaDoc {
18     private static final long serialVersionUID = 3617859655330969141L;
19     protected String JavaDoc address;
20     protected String JavaDoc city;
21     protected String JavaDoc province;
22     protected String JavaDoc country;
23     protected String JavaDoc postalCode;
24
25     /**
26      * @hibernate.property column="address" not-null="false" length="150"
27      */

28     public String JavaDoc getAddress() {
29         return address;
30     }
31
32     /**
33      * @struts.validator type="required"
34      * @hibernate.property column="city" not-null="true" length="50"
35      */

36     public String JavaDoc getCity() {
37         return city;
38     }
39
40     /**
41      * @struts.validator type="required"
42      * @hibernate.property column="province" length="100"
43      */

44     public String JavaDoc getProvince() {
45         return province;
46     }
47
48     /**
49      * @struts.validator type="required"
50      * @hibernate.property column="country" length="100"
51      */

52     public String JavaDoc getCountry() {
53         return country;
54     }
55
56     /**
57      * @struts.validator type="required"
58      * @struts.validator type="mask" msgkey="errors.zip"
59      * @struts.validator-var name="mask" value="${zip}"
60      * @hibernate.property column="postal_code" not-null="true" length="15"
61      */

62     public String JavaDoc getPostalCode() {
63         return postalCode;
64     }
65
66     public void setAddress(String JavaDoc address) {
67         this.address = address;
68     }
69
70     public void setCity(String JavaDoc city) {
71         this.city = city;
72     }
73
74     public void setCountry(String JavaDoc country) {
75         this.country = country;
76     }
77
78     public void setPostalCode(String JavaDoc postalCode) {
79         this.postalCode = postalCode;
80     }
81
82     public void setProvince(String JavaDoc province) {
83         this.province = province;
84     }
85
86     public boolean equals(Object JavaDoc o) {
87         if (this == o) return true;
88         if (!(o instanceof Address)) return false;
89
90         final Address address1 = (Address) o;
91
92         if (address != null ? !address.equals(address1.address) : address1.address != null) return false;
93         if (city != null ? !city.equals(address1.city) : address1.city != null) return false;
94         if (country != null ? !country.equals(address1.country) : address1.country != null) return false;
95         if (postalCode != null ? !postalCode.equals(address1.postalCode) : address1.postalCode != null) return false;
96         if (province != null ? !province.equals(address1.province) : address1.province != null) return false;
97
98         return true;
99     }
100
101     public int hashCode() {
102         int result;
103         result = (address != null ? address.hashCode() : 0);
104         result = 29 * result + (city != null ? city.hashCode() : 0);
105         result = 29 * result + (province != null ? province.hashCode() : 0);
106         result = 29 * result + (country != null ? country.hashCode() : 0);
107         result = 29 * result + (postalCode != null ? postalCode.hashCode() : 0);
108         return result;
109     }
110
111     public String JavaDoc toString() {
112         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
113                 .append("country", this.country)
114                 .append("address", this.address).append("province",
115                         this.province).append("postalCode", this.postalCode)
116                 .append("city", this.city).toString();
117     }
118 }
119
Popular Tags