001/******************************************************************************* 002 * Copyright 2014 The MITRE Corporation 003 * and the MIT Kerberos and Internet Trust Consortium 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * 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, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 ******************************************************************************/ 017package org.mitre.openid.connect.model; 018 019import javax.persistence.Basic; 020import javax.persistence.Column; 021import javax.persistence.Entity; 022import javax.persistence.GeneratedValue; 023import javax.persistence.GenerationType; 024import javax.persistence.Id; 025import javax.persistence.Table; 026 027@Entity 028@Table(name="address") 029public class Address { 030 031 032 private Long id; 033 private String formatted; 034 private String streetAddress; 035 private String locality; 036 private String region; 037 private String postalCode; 038 private String country; 039 040 /** 041 * Empty constructor 042 */ 043 public Address() { 044 045 } 046 047 /** 048 * @return the formatted address string 049 */ 050 @Basic 051 @Column(name = "formatted") 052 public String getFormatted() { 053 return formatted; 054 } 055 /** 056 * @param formatted the formatted address to set 057 */ 058 public void setFormatted(String formatted) { 059 this.formatted = formatted; 060 } 061 /** 062 * @return the streetAddress 063 */ 064 @Basic 065 @Column(name="street_address") 066 public String getStreetAddress() { 067 return streetAddress; 068 } 069 /** 070 * @param streetAddress the streetAddress to set 071 */ 072 public void setStreetAddress(String streetAddress) { 073 this.streetAddress = streetAddress; 074 } 075 /** 076 * @return the locality 077 */ 078 @Basic 079 @Column(name = "locality") 080 public String getLocality() { 081 return locality; 082 } 083 /** 084 * @param locality the locality to set 085 */ 086 public void setLocality(String locality) { 087 this.locality = locality; 088 } 089 /** 090 * @return the region 091 */ 092 @Basic 093 @Column(name = "region") 094 public String getRegion() { 095 return region; 096 } 097 /** 098 * @param region the region to set 099 */ 100 public void setRegion(String region) { 101 this.region = region; 102 } 103 /** 104 * @return the postalCode 105 */ 106 @Basic 107 @Column(name="postal_code") 108 public String getPostalCode() { 109 return postalCode; 110 } 111 /** 112 * @param postalCode the postalCode to set 113 */ 114 public void setPostalCode(String postalCode) { 115 this.postalCode = postalCode; 116 } 117 /** 118 * @return the country 119 */ 120 @Basic 121 @Column(name = "country") 122 public String getCountry() { 123 return country; 124 } 125 /** 126 * @param country the country to set 127 */ 128 public void setCountry(String country) { 129 this.country = country; 130 } 131 132 /** 133 * @return the id 134 */ 135 @Id 136 @GeneratedValue(strategy=GenerationType.IDENTITY) 137 @Column(name = "id") 138 public Long getId() { 139 return id; 140 } 141 142 /** 143 * @param id the id to set 144 */ 145 public void setId(Long id) { 146 this.id = id; 147 } 148 149 /* (non-Javadoc) 150 * @see java.lang.Object#hashCode() 151 */ 152 @Override 153 public int hashCode() { 154 final int prime = 31; 155 int result = 1; 156 result = prime * result + ((country == null) ? 0 : country.hashCode()); 157 result = prime * result + ((formatted == null) ? 0 : formatted.hashCode()); 158 result = prime * result + ((id == null) ? 0 : id.hashCode()); 159 result = prime * result + ((locality == null) ? 0 : locality.hashCode()); 160 result = prime * result + ((postalCode == null) ? 0 : postalCode.hashCode()); 161 result = prime * result + ((region == null) ? 0 : region.hashCode()); 162 result = prime * result + ((streetAddress == null) ? 0 : streetAddress.hashCode()); 163 return result; 164 } 165 166 /* (non-Javadoc) 167 * @see java.lang.Object#equals(java.lang.Object) 168 */ 169 @Override 170 public boolean equals(Object obj) { 171 if (this == obj) { 172 return true; 173 } 174 if (obj == null) { 175 return false; 176 } 177 if (!(obj instanceof Address)) { 178 return false; 179 } 180 Address other = (Address) obj; 181 if (country == null) { 182 if (other.country != null) { 183 return false; 184 } 185 } else if (!country.equals(other.country)) { 186 return false; 187 } 188 if (formatted == null) { 189 if (other.formatted != null) { 190 return false; 191 } 192 } else if (!formatted.equals(other.formatted)) { 193 return false; 194 } 195 if (id == null) { 196 if (other.id != null) { 197 return false; 198 } 199 } else if (!id.equals(other.id)) { 200 return false; 201 } 202 if (locality == null) { 203 if (other.locality != null) { 204 return false; 205 } 206 } else if (!locality.equals(other.locality)) { 207 return false; 208 } 209 if (postalCode == null) { 210 if (other.postalCode != null) { 211 return false; 212 } 213 } else if (!postalCode.equals(other.postalCode)) { 214 return false; 215 } 216 if (region == null) { 217 if (other.region != null) { 218 return false; 219 } 220 } else if (!region.equals(other.region)) { 221 return false; 222 } 223 if (streetAddress == null) { 224 if (other.streetAddress != null) { 225 return false; 226 } 227 } else if (!streetAddress.equals(other.streetAddress)) { 228 return false; 229 } 230 return true; 231 } 232 233}