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 java.util.ArrayList; 022import java.util.List; 023 024import javax.validation.Valid; 025import javax.validation.constraints.NotNull; 026import javax.xml.bind.annotation.XmlAccessType; 027import javax.xml.bind.annotation.XmlAccessorType; 028import javax.xml.bind.annotation.XmlElement; 029import javax.xml.bind.annotation.XmlType; 030 031 032/** 033 * = The Trade transaction. 034 * 035 * A Trade contains "global" agreements, delivery and settlement. On Item basis those parameters can be refined. 036 */ 037@XmlAccessorType(XmlAccessType.FIELD) 038@XmlType(name = "SupplyChainTradeTransactionType", propOrder = { "agreement", "delivery", "settlement","items" }) 039public class Trade { 040 041 @NotNull 042 @XmlElement(name = "ApplicableSupplyChainTradeAgreement") 043 private Agreement agreement; 044 045 @Valid 046 @XmlElement(name = "ApplicableSupplyChainTradeDelivery") 047 private Delivery delivery; 048 049 @Valid 050 @XmlElement(name = "ApplicableSupplyChainTradeSettlement") 051 private Settlement settlement; 052 053 @Valid 054 @XmlElement(name = "IncludedSupplyChainTradeLineItem") 055 private List<Item> items; 056 057 /** 058 * Gets the trade agreement. 059 * 060 * @return the agreement 061 */ 062 public Agreement getAgreement() { 063 return agreement; 064 } 065 066 /** 067 * Sets the trade agreement. 068 * 069 * @param agreement the new agreement 070 * @return the trade 071 */ 072 public Trade setAgreement(Agreement agreement) { 073 this.agreement = agreement; 074 return this; 075 } 076 077 /** 078 * Gets the trade delivery. 079 * 080 * @return the trade delivery 081 */ 082 public Delivery getDelivery() { 083 return delivery; 084 } 085 086 /** 087 * Sets the trade delivery. 088 * 089 * @param delivery the new trade delivery 090 * @return the trade 091 */ 092 public Trade setDelivery(Delivery delivery) { 093 this.delivery = delivery; 094 return this; 095 } 096 097 /** 098 * Gets the trade settlement. 099 * 100 * @return the trade settlement 101 */ 102 public Settlement getSettlement() { 103 return settlement; 104 } 105 106 /** 107 * Sets the trade settlement. 108 * 109 * @param tradeSettlement the new trade settlement 110 * @return the trade 111 */ 112 public Trade setSettlement(Settlement tradeSettlement) { 113 this.settlement = tradeSettlement; 114 return this; 115 } 116 117 /** 118 * Gets the item. 119 * 120 * @return the items 121 */ 122 public List<Item> getItems() { 123 if (items == null) { 124 items = new ArrayList<Item>(); 125 } 126 return this.items; 127 } 128 129 /** 130 * Adds an item. 131 * 132 * @param item the item 133 * @return the trade 134 */ 135 public Trade addItem(Item item) { 136 getItems().add(item); 137 return this; 138 } 139 140}