001/*
002 * Copyright (C) 2014 konik.io
003 *
004 * This file is part of Konik library.
005 *
006 * Konik library is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU Affero General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * Konik library is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU Affero General Public License for more details.
015 *
016 * You should have received a copy of the GNU Affero General Public License
017 * along with Konik library.  If not, see <http://www.gnu.org/licenses/>.
018 */
019package io.konik.zugferd.entity;
020
021import io.konik.zugferd.unqualified.ID;
022
023import java.util.ArrayList;
024import java.util.List;
025
026import javax.validation.Valid;
027import javax.xml.bind.annotation.XmlAccessType;
028import javax.xml.bind.annotation.XmlAccessorType;
029import javax.xml.bind.annotation.XmlElement;
030import javax.xml.bind.annotation.XmlType;
031import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
032import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
033
034import com.neovisionaries.i18n.CountryCode;
035
036/**
037 * = The Trade Product
038 */
039@XmlAccessorType(XmlAccessType.FIELD)
040@XmlType(name = "TradeProductType", propOrder = { "globalId", "sellerAssignedId", "buyerAssignedId", "name",
041      "description", "origins" })
042public class Product {
043
044   @XmlElement(name = "GlobalID")
045   private ID globalId;
046
047   @XmlElement(name = "SellerAssignedID")
048   @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
049   private String sellerAssignedId;
050
051   @XmlElement(name = "BuyerAssignedID")
052   @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
053   private String buyerAssignedId;
054
055   @XmlElement(name = "Name")
056   private String name;
057
058   @XmlElement(name = "Description")
059   private String description;
060
061   @Valid
062   @XmlElement(name = "OriginTradeCountry")
063   private List<CountryCode> origins;
064
065   /**
066    * Gets the global id.
067    *
068    * @return the global id
069    */
070   public ID getGlobalId() {
071      return globalId;
072   }
073
074   /**
075    * Sets the global id.
076    *
077    * @param productGlobalId the product global id
078    * @return the trade product
079    */
080   public Product setGlobalId(ID productGlobalId) {
081      this.globalId = productGlobalId;
082      return this;
083   }
084
085   /**
086    * Gets the seller assigned id.
087    *
088    * @return the seller assigned id
089    */
090   public String getSellerAssignedId() {
091      return sellerAssignedId;
092   }
093
094   /**
095    * Sets the seller assigned id.
096    *
097    * @param sellerAssignedId the new seller assigned id
098    * @return the trade product
099    */
100   public Product setSellerAssignedId(String sellerAssignedId) {
101      this.sellerAssignedId = sellerAssignedId;
102      return this;
103   }
104
105   /**
106    * Gets the buyer assigned id.
107    *
108    * @return the buyer assigned id
109    */
110   public String getBuyerAssignedId() {
111      return buyerAssignedId;
112   }
113
114   /**
115    * Sets the buyer assigned id.
116    *
117    * @param buyerAssignedId the new buyer assigned id
118    * @return the trade product
119    */
120   public Product setBuyerAssignedId(String buyerAssignedId) {
121      this.buyerAssignedId = buyerAssignedId;
122      return this;
123   }
124
125   /**
126    * Gets the name.
127    *
128    * @return the name
129    */
130   public String getName() {
131      return name;
132   }
133
134   /**
135    * Sets the name.
136    *
137    * @param name the new name
138    * @return the trade product
139    */
140   public Product setName(String name) {
141      this.name = name;
142      return this;
143   }
144
145   /**
146    * Gets the description.
147    *
148    * @return the description
149    */
150   public String getDescription() {
151      return description;
152   }
153
154   /**
155    * Sets the description.
156    *
157    * @param description the new description
158    * @return the product
159    */
160   public Product setDescription(String description) {
161      this.description = description;
162      return this;
163   }
164
165   /**
166    * Gets the origin trade country.
167    *
168    * @return the origin trade country
169    */
170   public List<CountryCode> getOrigins() {
171      if (origins == null) {
172         origins = new ArrayList<CountryCode>();
173      }
174      return origins;
175   }
176
177   /**
178    * Adds a origin trade country.
179    *
180    * @param originCountry the additional origin country
181    * @return the trade product
182    */
183   public Product addOrigins(CountryCode originCountry) {
184      getOrigins().add(originCountry);
185      return this;
186   }
187
188}