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