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.qualified.DateTime; 022import io.konik.zugferd.unece.codes.DateTimeType; 023 024import java.util.Date; 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; 031 032 033/** 034 * = The Delivery Event 035 * 036 */ 037@XmlAccessorType(XmlAccessType.FIELD) 038@XmlType(name = "SupplyChainEventType", propOrder = { "occurrence" }) 039public class Event { 040 041 @Valid 042 @XmlElement(name = "OccurrenceDateTime") 043 private DateTime occurrence; 044 045 /** Instantiates a new supply chain event. */ 046 public Event() { 047 } 048 049 /** 050 * Instantiates a new event. 051 * 052 * @param type the type 053 * @param date the date 054 */ 055 public Event(DateTimeType type, Date date) { 056 this.occurrence = new DateTime(type, date); 057 } 058 /** 059 * Instantiates a new supply chain event and sets the first event. 060 * 061 * @param dateTime the date time 062 */ 063 public Event(DateTime dateTime) { 064 setOccurrence(dateTime); 065 } 066 067 /** 068 * Gets the occurrence. 069 * 070 * @return the occurrence 071 */ 072 public DateTime getOccurrence() { 073 return occurrence; 074 } 075 076 /** 077 * Sets the occurrence. 078 * 079 * @param occurrence the new occurrence 080 * @return the event 081 */ 082 public Event setOccurrence(DateTime occurrence) { 083 this.occurrence = occurrence; 084 return this; 085 } 086 087 /** 088 * Gets the occurrence. 089 * 090 * @return the occurrence 091 */ 092 public Date getOccurrenceAsDate() { 093 return occurrence.asDate(); 094 } 095 096 097}