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;
022import com.google.common.base.Objects;
023
024@XmlRootElement(name = "address")
025public class Address extends RecurlyObject {
026
027    @XmlElement(name = "first_name")
028    private String firstName;
029
030    @XmlElement(name = "last_name")
031    private String lastName;
032
033    @XmlElement(name = "name_on_account")
034    private String nameOnAccount;
035
036    @XmlElement(name = "company")
037    private String company;
038
039    @XmlElement(name = "address1")
040    private String address1;
041
042    @XmlElement(name = "address2")
043    private String address2;
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 = "phone")
058    private String phone;
059
060    @XmlElement(name = "geo_code")
061    private String geoCode;
062
063    public String getFirstName() {
064        return firstName;
065    }
066
067    public void setFirstName(final Object firstName) {
068        this.firstName = stringOrNull(firstName);
069    }
070
071    public String getLastName() {
072        return lastName;
073    }
074
075    public void setLastName(final Object lastName) {
076        this.lastName = stringOrNull(lastName);
077    }
078
079    public String getNameOnAccount() {
080        return nameOnAccount;
081    }
082
083    public void setNameOnAccount(final Object nameOnAccount) {
084        this.nameOnAccount = stringOrNull(nameOnAccount);
085    }
086
087    public String getCompany() {
088        return company;
089    }
090
091    public void setCompany(final Object company) {
092        this.company = stringOrNull(company);
093    }
094
095    public String getAddress1() {
096        return address1;
097    }
098
099    public void setAddress1(final Object address1) {
100        this.address1 = stringOrNull(address1);
101    }
102
103    public String getAddress2() {
104        return address2;
105    }
106
107    public void setAddress2(final Object address2) {
108        this.address2 = stringOrNull(address2);
109    }
110
111    public String getCity() {
112        return city;
113    }
114
115    public void setCity(final Object city) {
116        this.city = stringOrNull(city);
117    }
118
119    public String getState() {
120        return state;
121    }
122
123    public void setState(final Object state) {
124        this.state = stringOrNull(state);
125    }
126
127    public String getZip() {
128        return zip;
129    }
130
131    public void setZip(final Object zip) {
132        this.zip = stringOrNull(zip);
133    }
134
135    public String getCountry() {
136        return country;
137    }
138
139    public void setCountry(final Object country) {
140        this.country = stringOrNull(country);
141    }
142
143    public String getPhone() {
144        return phone;
145    }
146
147    public void setPhone(final Object phone) {
148        this.phone = stringOrNull(phone);
149    }
150
151    public String getGeoCode() {
152        return geoCode;
153    }
154
155    public void setGeoCode(final Object geoCode) {
156        this.geoCode = stringOrNull(geoCode);
157    }
158
159    @Override
160    public String toString() {
161        final StringBuilder sb = new StringBuilder("Address{");
162        sb.append("firstName='").append(firstName).append('\'');
163        sb.append(", lastName='").append(lastName).append('\'');
164        sb.append(", nameOnAccount='").append(nameOnAccount).append('\'');
165        sb.append(", company='").append(company).append('\'');
166        sb.append(", address1='").append(address1).append('\'');
167        sb.append(", address2='").append(address2).append('\'');
168        sb.append(", city='").append(city).append('\'');
169        sb.append(", state='").append(state).append('\'');
170        sb.append(", zip=").append(zip);
171        sb.append(", country='").append(country).append('\'');
172        sb.append(", phone='").append(phone).append('\'');
173        sb.append(", geoCode='").append(geoCode).append('\'');
174        sb.append('}');
175        return sb.toString();
176    }
177
178    @Override
179    public boolean equals(final Object o) {
180        if (this == o) return true;
181        if (o == null || getClass() != o.getClass()) return false;
182
183        final Address address = (Address) o;
184
185        if (firstName != null ? !firstName.equals(address.firstName) : address.firstName != null) {
186            return false;
187        }
188        if (lastName != null ? !lastName.equals(address.lastName) : address.lastName != null) {
189            return false;
190        }
191        if (nameOnAccount != null ? !nameOnAccount.equals(address.nameOnAccount) : address.nameOnAccount != null) {
192            return false;
193        }
194        if (company != null ? !company.equals(address.company) : address.company != null) {
195            return false;
196        }
197        if (address1 != null ? !address1.equals(address.address1) : address.address1 != null) {
198            return false;
199        }
200        if (address2 != null ? !address2.equals(address.address2) : address.address2 != null) {
201            return false;
202        }
203        if (city != null ? !city.equals(address.city) : address.city != null) {
204            return false;
205        }
206        if (country != null ? !country.equals(address.country) : address.country != null) {
207            return false;
208        }
209        if (phone != null ? !phone.equals(address.phone) : address.phone != null) {
210            return false;
211        }
212        if (state != null ? !state.equals(address.state) : address.state != null) {
213            return false;
214        }
215        if (zip != null ? !zip.equals(address.zip) : address.zip != null) {
216            return false;
217        }
218        if (geoCode != null ? !geoCode.equals(address.geoCode) : address.geoCode != null) {
219            return false;
220        }
221
222        return true;
223    }
224
225
226    @Override
227    public int hashCode() {
228        return Objects.hashCode(
229                firstName,
230                lastName,
231                nameOnAccount,
232                company,
233                address1,
234                address2,
235                city,
236                state,
237                zip,
238                country,
239                phone,
240                geoCode
241        );
242    }
243}