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