001/*
002 * Copyright 2010-2014 Ning, Inc.
003 * Copyright 2014-2015 The Billing Project, LLC
004 *
005 * The Billing Project licenses this file to you under the Apache License, version 2.0
006 * (the "License"); you may not use this file except in compliance with the
007 * License.  You may obtain a copy of the License at:
008 *
009 *    http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
014 * License for the specific language governing permissions and limitations
015 * under the License.
016 */
017
018package com.ning.billing.recurly.model;
019
020import javax.xml.bind.annotation.XmlElement;
021import javax.xml.bind.annotation.XmlRootElement;
022
023import org.joda.time.DateTime;
024
025import com.google.common.base.Objects;
026
027@XmlRootElement(name = "shipping_address")
028public class ShippingAddress extends RecurlyObject {
029
030    @XmlElement(name = "id")
031    private Long id;
032
033    @XmlElement(name = "address1")
034    private String address1;
035
036    @XmlElement(name = "address2")
037    private String address2;
038
039    @XmlElement(name = "first_name")
040    private String firstName;
041
042    @XmlElement(name = "last_name")
043    private String lastName;
044
045    @XmlElement(name = "city")
046    private String city;
047
048    @XmlElement(name = "state")
049    private String state;
050
051    @XmlElement(name = "zip")
052    private String zip;
053
054    @XmlElement(name = "country")
055    private String country;
056
057    @XmlElement(name = "nickname")
058    private String nickname;
059
060    @XmlElement(name = "company")
061    private String company;
062
063    @XmlElement(name = "email")
064    private String email;
065
066    @XmlElement(name = "phone")
067    private String phone;
068
069    @XmlElement(name = "geo_code")
070    private String geoCode;
071
072    @XmlElement(name = "vat_number")
073    private String vatNumber;
074
075    @XmlElement(name = "created_at")
076    private DateTime createdAt;
077
078    @XmlElement(name = "updated_at")
079    private DateTime updatedAt;
080
081    public void setId(final Object id) {
082        this.id = longOrNull(id);
083    }
084
085    public Long getId() {
086        return this.id;
087    }
088
089    public String getAddress1() {
090        return address1;
091    }
092
093    public void setAddress1(final Object address1) {
094        this.address1 = stringOrNull(address1);
095    }
096
097    public String getAddress2() {
098        return address2;
099    }
100
101    public void setAddress2(final Object address2) {
102        this.address2 = stringOrNull(address2);
103    }
104
105    public String getCity() {
106        return city;
107    }
108
109    public void setCity(final Object city) {
110        this.city = stringOrNull(city);
111    }
112
113    public String getCompany() {
114        return company;
115    }
116
117    public void setCompany(final Object company) {
118        this.company = stringOrNull(company);
119    }
120
121    public String getState() {
122        return state;
123    }
124
125    public void setState(final Object state) {
126        this.state = stringOrNull(state);
127    }
128
129    public String getZip() {
130        return zip;
131    }
132
133    public void setZip(final Object zip) {
134        this.zip = stringOrNull(zip);
135    }
136
137    public String getCountry() {
138        return country;
139    }
140
141    public void setCountry(final Object country) {
142        this.country = stringOrNull(country);
143    }
144
145    public String getPhone() {
146        return phone;
147    }
148
149    public void setPhone(final Object phone) {
150        this.phone = stringOrNull(phone);
151    }
152
153    public String getNickname() {
154        return nickname;
155    }
156
157    public void setNickname(final Object nickname) {
158        this.nickname = stringOrNull(nickname);
159    }
160
161    public String getFirstName() {
162        return firstName;
163    }
164
165    public void setFirstName(final Object firstName) {
166        this.firstName = stringOrNull(firstName);
167    }
168
169    public String getLastName() {
170        return lastName;
171    }
172
173    public void setLastName(final Object lastName) {
174        this.lastName = stringOrNull(lastName);
175    }
176
177    public String getEmail() {
178        return email;
179    }
180
181    public void setEmail(final Object email) {
182        this.email = stringOrNull(email);
183    }
184
185    public String getGeoCode() { return geoCode; }
186
187    public void setGeoCode(final Object geoCode) { this.geoCode = stringOrNull(geoCode); }
188
189    public String getVatNumber() { return vatNumber; }
190
191    public void setVatNumber(final Object vatNumber) { this.vatNumber = stringOrNull(vatNumber); }
192
193    public DateTime getCreatedAt() {
194        return createdAt;
195    }
196
197    public void setCreatedAt(final Object createdAt) {
198        this.createdAt = dateTimeOrNull(createdAt);
199    }
200
201    public DateTime getUpdatedAt() {
202        return updatedAt;
203    }
204
205    public void setUpdatedAt(final Object updatedAt) {
206        this.updatedAt = dateTimeOrNull(updatedAt);
207    }
208
209    @Override
210    public String toString() {
211        final StringBuilder sb = new StringBuilder();
212        sb.append("ShippingAddress");
213        sb.append("{address1=").append(address1);
214        sb.append(", address2=").append(address2);
215        sb.append(", city=").append(city);
216        sb.append(", company=").append(company);
217        sb.append(", country=").append(country);
218        sb.append(", email=").append(email);
219        sb.append(", firstName=").append(firstName);
220        sb.append(", id=").append(id);
221        sb.append(", lastName=").append(lastName);
222        sb.append(", nickname=").append(nickname);
223        sb.append(", phone=").append(phone);
224        sb.append(", state=").append(state);
225        sb.append(", updatedAt=").append(updatedAt);
226        sb.append(", zip=").append(zip);
227        sb.append(", geoCode='").append(geoCode).append('\'');
228        sb.append(", vatNumber=").append(vatNumber);
229        sb.append('}');
230        return sb.toString();
231    }
232
233    @Override
234    public boolean equals(final Object o) {
235        if (this == o) return true;
236        if (o == null || getClass() != o.getClass()) return false;
237
238        final ShippingAddress that = (ShippingAddress) o;
239
240        if (address1 != null ? !address1.equals(that.address1) : that.address1 != null) {
241            return false;
242        }
243        if (address2 != null ? !address2.equals(that.address2) : that.address2 != null) {
244            return false;
245        }
246        if (city != null ? !city.equals(that.city) : that.city != null) {
247            return false;
248        }
249        if (company != null ? !company.equals(that.company) : that.company != null) {
250            return false;
251        }
252        if (country != null ? !country.equals(that.country) : that.country != null) {
253            return false;
254        }
255        if (email != null ? !email.equals(that.email) : that.email != null) {
256            return false;
257        }
258        if (firstName != null ? !firstName.equals(that.firstName) : that.firstName != null) {
259            return false;
260        }
261        if (id != null ? !id.equals(that.id) : that.id != null) {
262            return false;
263        }
264        if (lastName != null ? !lastName.equals(that.lastName) : that.lastName != null) {
265            return false;
266        }
267        if (nickname != null ? !nickname.equals(that.nickname) : that.nickname != null) {
268            return false;
269        }
270        if (phone != null ? !phone.equals(that.phone) : that.phone != null) {
271            return false;
272        }
273        if (state != null ? !state.equals(that.state) : that.state != null) {
274            return false;
275        }
276        if (updatedAt != null ? updatedAt.compareTo(that.updatedAt) != 0 : that.updatedAt != null) {
277            return false;
278        }
279        if (zip != null ? !zip.equals(that.zip) : that.zip != null) {
280            return false;
281        }
282        if (geoCode != null ? !geoCode.equals(that.geoCode) : that.geoCode != null) {
283            return false;
284        }
285        if (vatNumber != null ? !vatNumber.equals(that.vatNumber) : that.vatNumber != null) {
286            return false;
287        }
288
289        return true;
290    }
291
292    @Override
293    public int hashCode() {
294        return Objects.hashCode(
295                address1,
296                address2,
297                city,
298                company,
299                country,
300                email,
301                createdAt,
302                firstName,
303                id,
304                lastName,
305                nickname,
306                phone,
307                state,
308                zip,
309                geoCode,
310                vatNumber
311        );
312    }
313}