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