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