KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.objectweb.rentacar.persistance.bo;
2
3 import javax.persistence.Entity;
4 import javax.persistence.GeneratedValue;
5 import javax.persistence.Id;
6
7 import org.hibernate.annotations.GenericGenerator;
8 import org.apache.commons.lang.builder.EqualsBuilder;
9 import org.apache.commons.lang.builder.HashCodeBuilder;
10 import org.apache.commons.lang.builder.ToStringBuilder;
11 import org.apache.commons.lang.builder.CompareToBuilder;
12
13 /**
14  *
15  * @author ofabre
16  *
17  */

18 @Entity
19 public class Address implements Comparable JavaDoc {
20     
21     private String JavaDoc addressId;
22     
23     private String JavaDoc address;
24     
25     private String JavaDoc city;
26     
27     private String JavaDoc zip;
28     
29     private String JavaDoc country;
30
31
32     public Address() {
33         super();
34     }
35
36     /**
37      * Class constructor
38      * @param address Number on the street and street name
39      * @param city Name of the city
40      * @param zip Zip code of the city
41      * @param country Name of the country
42      */

43     public Address(String JavaDoc address, String JavaDoc city, String JavaDoc zip, String JavaDoc country) {
44         super();
45         this.address = address;
46         this.city = city;
47         this.zip = zip;
48         this.country = country;
49     }
50     
51     /**
52      * Class constructor
53      * @param addressId Id of the address
54      * @param address Number on the street and street name
55      * @param city Name of the city
56      * @param zip Zip code of the city
57      * @param country Name of the country
58      */

59     public Address(String JavaDoc addressId, String JavaDoc address, String JavaDoc city, String JavaDoc zip, String JavaDoc country) {
60         super();
61         this.addressId = addressId;
62         this.address = address;
63         this.city = city;
64         this.zip = zip;
65         this.country = country;
66     }
67     
68     /**
69      * Creates an Address object from an AddressVO object
70      * @param addressVO
71      */

72     public Address(AddressVO addressVO){
73         super();
74         this.addressId = addressVO.getAddressId();
75         this.address = addressVO.getAddress();
76         this.city = addressVO.getCity();
77         this.zip = addressVO.getZip();
78         this.country = addressVO.getCountry();
79     }
80
81     public String JavaDoc getAddress() {
82         return address;
83     }
84
85     public void setAddress(String JavaDoc address) {
86         this.address = address;
87     }
88
89     @Id @GeneratedValue(generator = "system-uuid")
90     @GenericGenerator(name="system-uuid", strategy = "uuid")
91     public String JavaDoc getAddressId() {
92         return addressId;
93     }
94
95     public void setAddressId(String JavaDoc addressId) {
96         this.addressId = addressId;
97     }
98
99     public String JavaDoc getCity() {
100         return city;
101     }
102
103     public void setCity(String JavaDoc city) {
104         this.city = city;
105     }
106
107     public String JavaDoc getCountry() {
108         return country;
109     }
110
111     public void setCountry(String JavaDoc country) {
112         this.country = country;
113     }
114
115     public String JavaDoc getZip() {
116         return zip;
117     }
118
119     public void setZip(String JavaDoc zip) {
120         this.zip = zip;
121     }
122
123     /**
124      * @see java.lang.Object#toString()
125      */

126     public String JavaDoc toString() {
127         return new ToStringBuilder(this).append("country", this.country)
128                 .append("address", this.address).append("addressId",
129                         this.addressId).append("zip", this.zip).append("city",
130                         this.city).toString();
131     }
132
133     /**
134      * @see java.lang.Object#equals(Object)
135      */

136     public boolean equals(Object JavaDoc object) {
137         if (!(object instanceof Address)) {
138             return false;
139         }
140         Address rhs = (Address) object;
141         return new EqualsBuilder().append(this.addressId, rhs.addressId)
142                 .append(this.country, rhs.country).append(this.address,
143                         rhs.address).append(this.zip, rhs.zip).append(
144                         this.city, rhs.city).isEquals();
145     }
146
147     /**
148      * @see java.lang.Object#hashCode()
149      */

150     public int hashCode() {
151         return new HashCodeBuilder(-1574159667, 218892883).append(
152                 this.addressId).append(this.country).append(this.address)
153                 .append(this.zip).append(this.city).toHashCode();
154     }
155
156     /**
157      * @see java.lang.Comparable#compareTo(Object)
158      */

159     public int compareTo(Object JavaDoc object) {
160         Address myClass = (Address) object;
161         return new CompareToBuilder().append(this.addressId, myClass.addressId)
162                 .append(this.country, myClass.country).append(this.address,
163                         myClass.address).append(this.zip, myClass.zip).append(
164                         this.city, myClass.city).toComparison();
165     }
166     
167     
168
169 }
170
Popular Tags