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 */ 018 019package io.konik.zugferd.entity; 020 021import io.konik.validator.annotation.Extended; 022import io.konik.validator.annotation.NotEmpty; 023import io.konik.zugferd.unqualified.ID; 024import io.konik.zugferd.unqualified.Quantity; 025 026import javax.validation.Valid; 027import javax.xml.bind.annotation.XmlElement; 028import javax.xml.bind.annotation.XmlType; 029import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 030import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 031import java.io.Serializable; 032import java.util.ArrayList; 033import java.util.List; 034 035/** 036 * = The Referenced Product which is a included or part of another product. 037 * 038 */ 039@Extended 040@XmlType(name = "ReferencedProductType", propOrder = { "globalIds", "sellerAssignedId", "buyerAssignedId", "names", 041 "descriptions", "units" }) 042public class ReferencedProduct implements Serializable { 043 044 045 @XmlElement(name = "GlobalID") 046 private List<ID> globalIds; 047 048 @XmlElement(name = "SellerAssignedID") 049 @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 050 private String sellerAssignedId; 051 052 @XmlElement(name = "BuyerAssignedID") 053 @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 054 private String buyerAssignedId; 055 056 @XmlElement(name = "Name") 057 private List<String> names; 058 059 @XmlElement(name = "Description") 060 private List<String> descriptions; 061 062 @XmlElement(name = "UnitQuantity") 063 private List<Quantity> units; 064 065 /** 066 * Gets the global ids. 067 * 068 * @return the global ids 069 */ 070 @Valid 071 public List<ID> getGlobalIds() { 072 if (globalIds == null) { 073 globalIds = new ArrayList<ID>(); 074 } 075 return this.globalIds; 076 } 077 078 /** 079 * Adds the global ids. 080 * 081 * @param globarId the globar id 082 * @return the referenced product 083 */ 084 public ReferencedProduct addGlobalIds(ID globarId) { 085 getGlobalIds().add(globarId); 086 return this; 087 } 088 089 /** 090 * Gets the seller assigned id. 091 * 092 * @return the seller assigned id 093 */ 094 public String getSellerAssignedId() { 095 return sellerAssignedId; 096 } 097 098 /** 099 * Sets the seller assigned id. 100 * 101 * @param sellerAsignedId the seller assigned id 102 */ 103 public void setSellerAssignedId(String sellerAsignedId) { 104 this.sellerAssignedId = sellerAsignedId; 105 } 106 107 /** 108 * Gets the buyer assigned id. 109 * 110 * @return the buyer assigned id 111 */ 112 public String getBuyerAssignedId() { 113 return buyerAssignedId; 114 } 115 116 /** 117 * Sets the buyer assigned id. 118 * 119 * @param buyerAssignedId the buyer assigned id 120 */ 121 public void setBuyerAssignedId(String buyerAssignedId) { 122 this.buyerAssignedId = buyerAssignedId; 123 } 124 125 /** 126 * Gets the names. 127 * 128 * @return the names 129 */ 130 @NotEmpty 131 public List<String> getNames() { 132 if (names == null) { 133 names = new ArrayList<String>(); 134 } 135 return this.names; 136 } 137 138 /** 139 * Adds the names. 140 * 141 * @param name the name 142 * @return the referenced product 143 */ 144 public ReferencedProduct addNames(String name) { 145 getNames().add(name); 146 return this; 147 } 148 149 /** 150 * Gets the descriptions. 151 * 152 * @return the descriptions 153 */ 154 public List<String> getDescriptions() { 155 if (descriptions == null) { 156 descriptions = new ArrayList<String>(); 157 } 158 return this.descriptions; 159 } 160 161 /** 162 * Adds the description. 163 * 164 * @param description the description 165 * @return the referenced product 166 */ 167 public ReferencedProduct addDescription(String description) { 168 getDescriptions().add(description); 169 return this; 170 } 171 172 /** 173 * Gets the units. 174 * 175 * @return the units 176 */ 177 @Valid 178 public List<Quantity> getUnits() { 179 if (units == null) { 180 units = new ArrayList<Quantity>(); 181 } 182 return this.units; 183 } 184 185 /** 186 * Adds the units. 187 * 188 * @param unit the unit 189 * @return the referenced product 190 */ 191 public ReferencedProduct addUnits(Quantity unit) { 192 getUnits().add(unit); 193 return this; 194 } 195 196}