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.profile; 019 020import java.io.Serializable; 021 022/** 023 * 024 * The ZUGFeRD Profile consists of three parts. The namespace the version and the conformance level. 025 */ 026public class Profile implements Serializable { 027 private static final String DELIMITER = ":"; 028 private static final String NS = "urn:ferd:CrossIndustryDocument:invoice:"; 029 030 private String namespace; 031 private ProfileVersion version; 032 private ConformanceLevel conformanceLevel; 033 034 /** 035 * Instantiates a new profile. 036 */ 037 public Profile() { 038 this.namespace = NS; 039 this.version = ProfileVersion.latestVersion(); 040 } 041 042 /** 043 * Instantiates a new profile with the latest version 044 * 045 * @param conformanceLevel the conformance level 046 */ 047 public Profile(ConformanceLevel conformanceLevel) { 048 super(); 049 this.namespace = NS; 050 this.version = ProfileVersion.latestVersion(); 051 this.conformanceLevel = conformanceLevel; 052 } 053 054 /** 055 * Instantiates a new profile. 056 * 057 * @param namespace the namespace 058 * @param version the version 059 * @param conformanceLevel the conformance level 060 */ 061 public Profile(String namespace, ProfileVersion version, ConformanceLevel conformanceLevel) { 062 super(); 063 this.namespace = namespace; 064 this.version = version; 065 this.conformanceLevel = conformanceLevel; 066 } 067 068 /** 069 * Gets the namespace. 070 * 071 * @return the namespace 072 */ 073 public String getNamespace() { 074 return namespace; 075 } 076 077 /** 078 * Sets the namespace. 079 * 080 * @param namespace the namespace 081 * @return the profile 082 */ 083 public Profile setNamespace(String namespace) { 084 this.namespace = namespace; 085 return this; 086 } 087 088 /** 089 * Gets the version. 090 * 091 * @return the version 092 */ 093 public ProfileVersion getVersion() { 094 return version; 095 } 096 097 /** 098 * Sets the version. 099 * 100 * @param version the new version 101 * @return the profile 102 */ 103 public Profile setVersion(ProfileVersion version) { 104 this.version = version; 105 return this; 106 } 107 108 /** 109 * Gets the conformance level. 110 * 111 * @return the conformance level 112 */ 113 public ConformanceLevel getConformanceLevel() { 114 return conformanceLevel; 115 } 116 117 /** 118 * Sets the conformance level. 119 * 120 * @param conformanceLevel the new conformance level 121 * @return the profile 122 */ 123 public Profile setConformanceLevel(ConformanceLevel conformanceLevel) { 124 this.conformanceLevel = conformanceLevel; 125 return this; 126 } 127 128 129 /** 130 * Gets the full name consisting of the namespace, version, conformance level. 131 * 132 * @return the full name 133 */ 134 public String fullName(){ 135 return namespace+version.toString()+DELIMITER+conformanceLevel.toString(); 136 } 137 138 139 140}