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 javax.xml.bind.annotation.XmlAccessType; 021import javax.xml.bind.annotation.XmlAccessorType; 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 029/** 030 * = The Address 031 * 032 * The postal address of an entity. 033 */ 034@XmlAccessorType(XmlAccessType.FIELD) 035@XmlType(name = "TradeAddressType", propOrder = { "postcode", "lineOne", "lineTwo", "city", "country" }) 036public class Address { 037 038 @XmlElement(name = "PostcodeCode") 039 @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 040 private String postcode; 041 042 @XmlElement(name = "LineOne") 043 private String lineOne; 044 045 @XmlElement(name = "LineTwo") 046 private String lineTwo; 047 048 @XmlElement(name = "CityName") 049 private String city; 050 051 @XmlElement(name = "CountryID") 052 private CountryCode country; 053 054 /** Instantiates a new trade address. */ 055 public Address() { 056 } 057 058 /** 059 * Instantiates a new trade address. 060 * 061 * @param postcode the postcode 062 * @param lineOne the line one 063 * @param lineTwo the line two 064 * @param cityName the city name 065 * @param countryCode the ISO 3166-2A country code 066 */ 067 public Address(String postcode, String lineOne, String lineTwo, String cityName, CountryCode countryCode) { 068 super(); 069 this.postcode = postcode; 070 this.lineOne = lineOne; 071 this.lineTwo = lineTwo; 072 this.city = cityName; 073 this.country = countryCode; 074 } 075 076 /** 077 * Instantiates a new trade address. 078 * 079 * @param postcode the postal code 080 * @param lineOne the line one 081 * @param cityName the city name 082 * @param countryCode the ISO 3166-2A country code 083 */ 084 public Address(String postcode, String lineOne, String cityName, CountryCode countryCode) { 085 super(); 086 this.postcode = postcode; 087 this.lineOne = lineOne; 088 this.city = cityName; 089 this.country = countryCode; 090 } 091 092 /** 093 * Gets the postcode. 094 * 095 * Profile:: BASIC when part of Trade.agreements.seller. 096 * 097 * Example:: {@code DE-123456} 098 * 099 * @return the postcode 100 */ 101 public String getPostcode() { 102 return postcode; 103 } 104 105 /** 106 * Sets the postcode code. 107 * 108 * Profile:: BASIC when part of Trade.agreements.seller. 109 * 110 * Example:: {@code DE-123456} 111 * 112 * @param postcode the postcode 113 * @return the trade address 114 */ 115 public Address setPostcode(String postcode) { 116 this.postcode = postcode; 117 return this; 118 } 119 120 /** 121 * Gets the line one. Usually the Street name. 122 * 123 * Profile:: BASIC when part of Trade.agreements.seller. 124 * 125 * Example:: {@code Elm Street 13} 126 * 127 * @return the line one 128 */ 129 public String getLineOne() { 130 return lineOne; 131 } 132 133 /** 134 * Sets the line one. Usually the Street name. 135 * 136 * Profile:: BASIC when part of Trade.agreements.seller. 137 * 138 * Example:: {@code Elm Street 13} 139 * 140 * @param lineOne the new line one 141 * @return the trade address 142 */ 143 public Address setLineOne(String lineOne) { 144 this.lineOne = lineOne; 145 return this; 146 } 147 148 /** 149 * Gets the line two. Location like Building name or department. 150 * 151 * Profile:: BASIC when part of Trade.agreements.seller. 152 * 153 * Example:: {@code Department of broken dreams} 154 * 155 * @return the line two 156 */ 157 public String getLineTwo() { 158 return lineTwo; 159 } 160 161 /** 162 * Sets the line two.. Location like Building name or department. 163 * 164 * Profile:: BASIC when part of Trade.agreements.seller. 165 * 166 * Example:: {@code Department of broken dreams} 167 * 168 * @param lineTwo the new line two 169 * @return the trade address 170 */ 171 public Address setLineTwo(String lineTwo) { 172 this.lineTwo = lineTwo; 173 return this; 174 } 175 176 /** 177 * Gets the city name. 178 * 179 * Profile:: BASIC when part of Trade.agreements.seller. 180 * 181 * Example:: {@code Zürich} 182 * 183 * @return the city name 184 */ 185 public String getCity() { 186 return city; 187 } 188 189 /** 190 * Sets the city name. 191 * 192 * Profile:: BASIC when part of Trade.agreements.seller. 193 * 194 * Example:: {@code Zürich} 195 * 196 * @param cityName the new city name 197 * @return the trade address 198 */ 199 public Address setCity(String cityName) { 200 this.city = cityName; 201 return this; 202 } 203 204 /** 205 * Gets the country. 206 * 207 * Two-letter country codes defined in ISO 3166-1, 208 * 209 * Profile:: BASIC when part of Trade.agreements.seller. 210 * 211 * Example:: {@code CH} 212 * 213 * @return the ISO 3166-2A country 214 * @see <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-2A Country Codes</a> 215 */ 216 public CountryCode getCountry() { 217 return country; 218 } 219 220 /** 221 * Sets the country. 222 * 223 * Two-letter country codes defined in ISO 3166-1, 224 * 225 * Profile:: BASIC when part of Trade.agreements.seller. 226 * 227 * Example:: {@code CH} 228 * 229 * @param country the country 230 * @return the trade address 231 * @see <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-2A Country Codes</a> 232 */ 233 public Address setCountry(CountryCode country) { 234 this.country = country; 235 return this; 236 } 237}