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.Basic;
021import io.konik.validator.annotation.Comfort;
022import io.konik.validator.annotation.Extended;
023import io.konik.validator.annotation.NotEmpty;
024import io.konik.validator.annotation.NullableNotBlank;
025
026import java.util.ArrayList;
027import java.util.List;
028
029import javax.xml.bind.annotation.XmlElement;
030import javax.xml.bind.annotation.XmlType;
031import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
032import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
033
034/**
035 * = The Note
036 */
037@XmlType(name = "NoteType", propOrder = { "contentCode", "contents", "subjectCode" })
038public class Note {
039
040   @Extended
041   @NullableNotBlank
042   @XmlElement(name = "ContentCode")
043   @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
044   private String contentCode;
045
046   @Basic
047   @NotEmpty
048   @XmlElement(name = "Content")
049   private List<String> contents;
050
051   @Comfort
052   @XmlElement(name = "SubjectCode")
053   @NullableNotBlank
054   @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
055   private String subjectCode;
056
057   /** Instantiates a new note. */
058   public Note() {
059   }
060
061   /**
062    * Instantiates a new note without a content only.
063    *
064    * @param content the content
065    */
066   public Note(String content) {
067      super();
068      addContent(content);
069   }
070
071   /**
072    * Instantiates a new note.
073    *
074    * @param content the content
075    * @param subjectCode the subject code
076    */
077   public Note(String content, String subjectCode) {
078      super();
079      this.addContent(content);
080      this.subjectCode = subjectCode;
081   }
082
083   /**
084    * Gets the content.
085    *
086    * @return the content
087    */
088   public List<String> getContents() {
089      if (contents == null) {
090         this.contents = new ArrayList<String>();
091      }
092      return this.contents;
093   }
094
095   /**
096    * Adds content
097    *
098    * @param content the additional content
099    * @return the note
100    */
101   public Note addContent(String content) {
102      getContents().add(content);
103      return this;
104   }
105
106   /**
107    * Gets the subject code.
108    * 
109    * @return the subject code
110    */
111   public String getSubjectCode() {
112      return subjectCode;
113   }
114
115   /**
116    * Sets the subject code.
117    *
118    * @param subjectCode the new subject code
119    * @return the note
120    */
121   public Note setSubjectCode(String subjectCode) {
122      this.subjectCode = subjectCode;
123      return this;
124   }
125
126   /**
127    * Gets the content code.
128    * 
129    *
130    * @return the content code
131    */
132   public String getContentCode() {
133      return contentCode;
134   }
135
136   /**
137    * Sets the content code.
138    * 
139    * @param contentCode the content code
140    * @return the note
141    */
142   public Note setContentCode(String contentCode) {
143      this.contentCode = contentCode;
144      return this;
145   }
146
147}