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 io.konik.validator.annotation.Basic; 021import io.konik.validator.annotation.Comfort; 022import io.konik.validator.annotation.Extended; 023 024import java.lang.annotation.Annotation; 025import java.util.Arrays; 026import java.util.List; 027 028import static io.konik.util.Strings.isNullOrEmpty; 029 030/** 031 * The latest Version Invoice Profiles. 032 */ 033public enum ConformanceLevel { 034 035 /** The conformance level basic*/ 036 BASIC, 037 /** The conformance level profile */ 038 COMFORT, 039 /** The conformance level extended */ 040 EXTENDED; 041 042 private static final String DELIMITER = ":"; 043 044 /** 045 * Instantiates a new profile type. 046 */ 047 ConformanceLevel() { 048 } 049 050 @Override 051 public String toString() { 052 return name().toLowerCase(); 053 } 054 055 /** 056 * Parses the full name and extract the conformance level 057 * 058 * @param fullName the full name 059 * @return the conformance level 060 */ 061 public static ConformanceLevel extractConformanceLevel(String fullName) { 062 if (isNullOrEmpty(fullName)) {throw new EnumConstantNotPresentException(ConformanceLevel.class, fullName);} 063 String[] tokens = fullName.split(DELIMITER); 064 int lastTokenPosition = tokens.length-1; 065 String level = tokens[lastTokenPosition]; 066 return valueOf(level.toUpperCase()); 067 } 068 069 public static List<Class<? extends Annotation>> getAnnotations() { 070 return Arrays.asList(Basic.class, Comfort.class, Extended.class); 071 } 072 073}