001/* 002 * Copyright 2010-2013 Ning, Inc. 003 * 004 * Ning licenses this file to you under the Apache License, version 2.0 005 * (the "License"); you may not use this file except in compliance with the 006 * License. You may obtain a copy of the License at: 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 013 * License for the specific language governing permissions and limitations 014 * under the License. 015 */ 016 017package com.ning.billing.recurly.model; 018 019import javax.xml.bind.annotation.XmlElement; 020import javax.xml.bind.annotation.XmlRootElement; 021 022@XmlRootElement(name = "account") 023public class Address extends RecurlyObject { 024 025 @XmlElement(name = "address1") 026 private String address1; 027 028 @XmlElement(name = "address2") 029 private String address2; 030 031 @XmlElement(name = "city") 032 private String city; 033 034 @XmlElement(name = "state") 035 private String state; 036 037 @XmlElement(name = "zip") 038 private String zip; 039 040 @XmlElement(name = "country") 041 private String country; 042 043 @XmlElement(name = "phone") 044 private String phone; 045 046 public String getAddress1() { 047 return address1; 048 } 049 050 public void setAddress1(final Object address1) { 051 this.address1 = stringOrNull(address1); 052 } 053 054 public String getAddress2() { 055 return address2; 056 } 057 058 public void setAddress2(final Object address2) { 059 this.address2 = stringOrNull(address2); 060 } 061 062 public String getCity() { 063 return city; 064 } 065 066 public void setCity(final Object city) { 067 this.city = stringOrNull(city); 068 } 069 070 public String getState() { 071 return state; 072 } 073 074 public void setState(final Object state) { 075 this.state = stringOrNull(state); 076 } 077 078 public String getZip() { 079 return zip; 080 } 081 082 public void setZip(final Object zip) { 083 this.zip = stringOrNull(zip); 084 } 085 086 public String getCountry() { 087 return country; 088 } 089 090 public void setCountry(final Object country) { 091 this.country = stringOrNull(country); 092 } 093 094 public String getPhone() { 095 return phone; 096 } 097 098 public void setPhone(final Object phone) { 099 this.phone = stringOrNull(phone); 100 } 101 102 @Override 103 public String toString() { 104 final StringBuilder sb = new StringBuilder("Address{"); 105 sb.append("address1='").append(address1).append('\''); 106 sb.append(", address2='").append(address2).append('\''); 107 sb.append(", city='").append(city).append('\''); 108 sb.append(", state='").append(state).append('\''); 109 sb.append(", zip=").append(zip); 110 sb.append(", country='").append(country).append('\''); 111 sb.append(", phone='").append(phone).append('\''); 112 sb.append('}'); 113 return sb.toString(); 114 } 115 116 @Override 117 public boolean equals(final Object o) { 118 if (this == o) { 119 return true; 120 } 121 if (o == null || getClass() != o.getClass()) { 122 return false; 123 } 124 125 final Address address = (Address) o; 126 127 if (address1 != null ? !address1.equals(address.address1) : address.address1 != null) { 128 return false; 129 } 130 if (address2 != null ? !address2.equals(address.address2) : address.address2 != null) { 131 return false; 132 } 133 if (city != null ? !city.equals(address.city) : address.city != null) { 134 return false; 135 } 136 if (country != null ? !country.equals(address.country) : address.country != null) { 137 return false; 138 } 139 if (phone != null ? !phone.equals(address.phone) : address.phone != null) { 140 return false; 141 } 142 if (state != null ? !state.equals(address.state) : address.state != null) { 143 return false; 144 } 145 if (zip != null ? !zip.equals(address.zip) : address.zip != null) { 146 return false; 147 } 148 149 return true; 150 } 151 152 @Override 153 public int hashCode() { 154 int result = address1 != null ? address1.hashCode() : 0; 155 result = 31 * result + (address2 != null ? address2.hashCode() : 0); 156 result = 31 * result + (city != null ? city.hashCode() : 0); 157 result = 31 * result + (state != null ? state.hashCode() : 0); 158 result = 31 * result + (zip != null ? zip.hashCode() : 0); 159 result = 31 * result + (country != null ? country.hashCode() : 0); 160 result = 31 * result + (phone != null ? phone.hashCode() : 0); 161 return result; 162 } 163}