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