001package ca.uhn.fhir.validation; 002 003/* 004 * #%L 005 * HAPI FHIR - Core Library 006 * %% 007 * Copyright (C) 2014 - 2021 Smile CDR, Inc. 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023import java.util.Collections; 024import java.util.HashMap; 025import java.util.Map; 026 027public enum ResultSeverityEnum { 028 029 /** 030 * The issue has no relation to the degree of success of the action 031 */ 032 INFORMATION("information"), 033 034 /** 035 * The issue is not important enough to cause the action to fail, but may cause it to be performed suboptimally or in a way that is not as desired 036 */ 037 WARNING("warning"), 038 039 /** 040 * The issue is sufficiently important to cause the action to fail 041 */ 042 ERROR("error"), 043 044 /** 045 * The issue caused the action to fail, and no further checking could be performed 046 */ 047 FATAL("fatal"); 048 049 private static Map<String, ResultSeverityEnum> ourValues; 050 private String myCode; 051 052 private ResultSeverityEnum(String theCode) { 053 myCode = theCode; 054 } 055 056 public String getCode() { 057 return myCode; 058 } 059 060 public static ResultSeverityEnum fromCode(String theCode) { 061 if (ourValues == null) { 062 HashMap<String, ResultSeverityEnum> values = new HashMap<String, ResultSeverityEnum>(); 063 for (ResultSeverityEnum next : values()) { 064 values.put(next.getCode(), next); 065 } 066 ourValues = Collections.unmodifiableMap(values); 067 } 068 return ourValues.get(theCode); 069 } 070 071 /** 072 * Convert from Enum ordinal to Enum type. 073 * 074 * Usage: 075 * 076 * <code>ResultSeverityEnum resultSeverityEnum = ResultSeverityEnum.values[ordinal];</code> 077 */ 078 public static final ResultSeverityEnum values[] = values(); 079}