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