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 */
018package io.konik.zugferd.entity;
019
020import static java.lang.Integer.valueOf;
021
022import java.util.ArrayList;
023import java.util.List;
024
025import javax.xml.bind.annotation.XmlAccessType;
026import javax.xml.bind.annotation.XmlAccessorType;
027import javax.xml.bind.annotation.XmlElement;
028import javax.xml.bind.annotation.XmlType;
029
030/**
031 * = The Item Line Document
032 * 
033 * For Item position and notes
034 */
035@XmlAccessorType(XmlAccessType.FIELD)
036@XmlType(name = "DocumentLineDocumentType", propOrder = { "position", "notes" })
037public class Document {
038
039   @XmlElement(name = "LineID")
040   private Integer position;
041
042   @XmlElement(name = "IncludedNote")
043   private List<Note> notes;
044
045   /**
046    * Instantiates a new document line.
047    */
048   public Document() {
049   }
050
051   /**
052    * Instantiates a new document line.
053    *
054    * @param position the position number
055    */
056   public Document(int position) {
057      super();
058      this.position = Integer.valueOf(position);
059   }
060
061   /**
062    * Instantiates a new document line.
063    *
064    * @param position the position
065    * @param notes the notes
066    */
067   public Document(int position, List<Note> notes) {
068      this(position);
069      this.notes = notes;
070   }
071
072   /**
073    * Gets the line position.
074    * 
075    * Profile:: COMFORT
076    *
077    * @return the position number
078    */
079   public Integer getPosition() {
080      return position == null ? null : position;
081   }
082
083   /**
084    * Sets the line position
085    * 
086    * Profile:: COMFORT.
087    *
088    * @param position the position
089    * @return the document line
090    */
091   public Document setPosition(int position) {
092      this.position = valueOf(position);
093      return this;
094   }
095
096   /**
097    * Gets the included note.
098    * 
099    * Profile::
100    * - Note.content COMFORT
101    * - Note.subjectCode EXTENDED
102    * 
103    * @return the included note
104    */
105   public List<Note> getNotes() {
106      if (notes == null) {
107         notes = new ArrayList<Note>();
108      }
109      return this.notes;
110   }
111
112   /**
113    * Adds the note.
114    * 
115    * Profile::
116    * - Note.content COMFORT
117    * - Note.subjectCode EXTENDED
118    *
119    * @param note the note
120    * @return the document line document
121    */
122   public Document addNote(Note note) {
123      getNotes().add(note);
124      return this;
125   }
126
127}