001/* Copyright (C) 2014 konik.io 002 * 003 * This file is part of the Konik library. 004 * 005 * The Konik library is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU Affero General Public License as 007 * published by the Free Software Foundation, either version 3 of the 008 * License, or (at your option) any later version. 009 * 010 * The Konik library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Affero General Public License for more details. 014 * 015 * You should have received a copy of the GNU Affero General Public License 016 * along with the Konik library. If not, see <http://www.gnu.org/licenses/>. 017 */ 018package io.konik.zugferd.entity; 019 020import java.io.Serializable; 021 022import javax.xml.bind.annotation.XmlElement; 023import javax.xml.bind.annotation.XmlType; 024import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 025import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 026 027import com.neovisionaries.i18n.CountryCode; 028 029import io.konik.validator.annotation.Basic; 030 031/** 032 * = The Address 033 * 034 * The postal address of an entity. 035 */ 036@XmlType(name = "TradeAddressType", propOrder = { "postcode", "lineOne", "lineTwo", "city", "country" }) 037public class Address implements Serializable { 038 039 @XmlElement(name = "PostcodeCode") 040 @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 041 private String postcode; 042 043 @XmlElement(name = "LineOne") 044 private String lineOne; 045 046 @XmlElement(name = "LineTwo") 047 private String lineTwo; 048 049 @XmlElement(name = "CityName") 050 private String city; 051 052 @XmlElement(name = "CountryID") 053 private CountryCode country; 054 055 /** Instantiates a new trade address. */ 056 public Address() { 057 } 058 059 /** 060 * Instantiates a new trade address. 061 * 062 * @param postcode the post code 063 * @param lineOne the line one 064 * @param lineTwo the line two 065 * @param cityName the city name 066 * @param countryCode the ISO 3166-2A country code 067 */ 068 public Address(String postcode, String lineOne, String lineTwo, String cityName, CountryCode countryCode) { 069 super(); 070 this.postcode = postcode; 071 this.lineOne = lineOne; 072 this.lineTwo = lineTwo; 073 this.city = cityName; 074 this.country = countryCode; 075 } 076 077 /** 078 * Instantiates a new trade address. 079 * 080 * @param postcode the postal code 081 * @param lineOne the line one 082 * @param cityName the city name 083 * @param countryCode the ISO 3166-2A country code 084 */ 085 public Address(String postcode, String lineOne, String cityName, CountryCode countryCode) { 086 super(); 087 this.postcode = postcode; 088 this.lineOne = lineOne; 089 this.city = cityName; 090 this.country = countryCode; 091 } 092 093 /** 094 * Gets the post code. 095 * 096 * Profile:: BASIC when part of Trade.agreements.seller. 097 * 098 * Example:: {@code DE-123456} 099 * 100 * @return the post code 101 */ 102 @Basic 103 public String getPostcode() { 104 return postcode; 105 } 106 107 /** 108 * Sets the post code. 109 * 110 * Profile:: BASIC when part of Trade.agreements.seller. 111 * 112 * Example:: {@code DE-123456} 113 * 114 * @param postcode the postcode 115 * @return the trade address 116 */ 117 public Address setPostcode(String postcode) { 118 this.postcode = postcode; 119 return this; 120 } 121 122 /** 123 * Gets the line one. Usually the Street name. 124 * 125 * Profile:: BASIC when part of Trade.agreements.seller. 126 * 127 * Example:: {@code Elm Street 13} 128 * 129 * @return the line one 130 */ 131 @Basic 132 public String getLineOne() { 133 return lineOne; 134 } 135 136 /** 137 * Sets the line one. Usually the Street name. 138 * 139 * Profile:: BASIC when part of Trade.agreements.seller. 140 * 141 * Example:: {@code Elm Street 13} 142 * 143 * @param lineOne the new line one 144 * @return the trade address 145 */ 146 public Address setLineOne(String lineOne) { 147 this.lineOne = lineOne; 148 return this; 149 } 150 151 /** 152 * Gets the line two. Location like Building name or department. 153 * 154 * Profile:: BASIC when part of Trade.agreements.seller. 155 * 156 * Example:: {@code Department of broken dreams} 157 * 158 * @return the line two 159 */ 160 @Basic 161 public String getLineTwo() { 162 return lineTwo; 163 } 164 165 /** 166 * Sets the line two.. Location like Building name or department. 167 * 168 * Profile:: BASIC when part of Trade.agreements.seller. 169 * 170 * Example:: {@code Department of broken dreams} 171 * 172 * @param lineTwo the new line two 173 * @return the trade address 174 */ 175 public Address setLineTwo(String lineTwo) { 176 this.lineTwo = lineTwo; 177 return this; 178 } 179 180 /** 181 * Gets the city name. 182 * 183 * Profile:: BASIC when part of Trade.agreements.seller. 184 * 185 * Example:: {@code Zürich} 186 * 187 * @return the city name 188 */ 189 @Basic 190 public String getCity() { 191 return city; 192 } 193 194 /** 195 * Sets the city name. 196 * 197 * Profile:: BASIC when part of Trade.agreements.seller. 198 * 199 * Example:: {@code Zürich} 200 * 201 * @param cityName the new city name 202 * @return the trade address 203 */ 204 public Address setCity(String cityName) { 205 this.city = cityName; 206 return this; 207 } 208 209 /** 210 * Gets the country. 211 * 212 * Two-letter country codes defined in ISO 3166-1, 213 * 214 * Profile:: BASIC when part of Trade.agreements.seller. 215 * 216 * Example:: {@code CH} 217 * 218 * @return the ISO 3166-2A country 219 * @see <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-2A Country Codes</a> 220 */ 221 @Basic 222 public CountryCode getCountry() { 223 return country; 224 } 225 226 /** 227 * Sets the country. 228 * 229 * Two-letter country codes defined in ISO 3166-1, 230 * 231 * Profile:: BASIC when part of Trade.agreements.seller. 232 * 233 * Example:: {@code CH} 234 * 235 * @param country the country 236 * @return the trade address 237 * @see <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-2A Country Codes</a> 238 */ 239 public Address setCountry(CountryCode country) { 240 this.country = country; 241 return this; 242 } 243}