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 */ 018 019package io.konik.zugferd.entity; 020 021import io.konik.validator.annotation.NotEmpty; 022import io.konik.zugferd.unqualified.Code; 023 024import javax.validation.Valid; 025import javax.validation.constraints.NotNull; 026import javax.xml.bind.annotation.XmlElement; 027import javax.xml.bind.annotation.XmlType; 028import java.io.Serializable; 029import java.util.ArrayList; 030import java.util.List; 031 032/** 033 * = The product classification. 034 */ 035@XmlType(name = "ProductClassificationType", propOrder = { "classCode", "classNames" }) 036public class ProductClassification implements Serializable { 037 038 @XmlElement(name = "ClassCode") 039 private Code classCode; 040 041 @XmlElement(name = "ClassName") 042 private List<String> classNames; 043 044 /** 045 * Gets the class code. 046 * 047 * @return the class code 048 */ 049 @Valid 050 @NotNull 051 public Code getClassCode() { 052 return classCode; 053 } 054 055 /** 056 * Sets the class code. 057 * 058 * @param value the class code 059 * @return the product classification 060 */ 061 public ProductClassification setClassCode(Code value) { 062 this.classCode = value; 063 return this; 064 } 065 066 /** 067 * Gets the class names. 068 * 069 * @return the class names 070 */ 071 @NotEmpty 072 public List<String> getClassNames() { 073 if (classNames == null) { 074 classNames = new ArrayList<String>(); 075 } 076 return this.classNames; 077 } 078 079 /** 080 * Adds the class names. 081 * 082 * @param className the class name 083 * @return the product classification 084 */ 085 public ProductClassification addClassNames(String className) { 086 getClassNames().add(className); 087 return this; 088 } 089 090}