
001 002package ca.uhn.fhir.model.valueset; 003 004/* 005 * #%L 006 * HAPI FHIR - Core Library 007 * %% 008 * Copyright (C) 2014 - 2023 Smile CDR, Inc. 009 * %% 010 * Licensed under the Apache License, Version 2.0 (the "License"); 011 * you may not use this file except in compliance with the License. 012 * You may obtain a copy of the License at 013 * 014 * http://www.apache.org/licenses/LICENSE-2.0 015 * 016 * Unless required by applicable law or agreed to in writing, software 017 * distributed under the License is distributed on an "AS IS" BASIS, 018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 019 * See the License for the specific language governing permissions and 020 * limitations under the License. 021 * #L% 022 */ 023 024import java.util.HashMap; 025import java.util.Map; 026 027import ca.uhn.fhir.model.api.IValueSetEnumBinder; 028import ca.uhn.fhir.util.CoverageIgnore; 029 030@CoverageIgnore 031public enum BundleTypeEnum { 032 033 TRANSACTION("transaction", "http://hl7.org/fhir/bundle-type"), 034 035 DOCUMENT("document", "http://hl7.org/fhir/bundle-type"), 036 037 MESSAGE("message", "http://hl7.org/fhir/bundle-type"), 038 039 BATCH_RESPONSE("batch-response", "http://hl7.org/fhir/bundle-type"), 040 041 TRANSACTION_RESPONSE("transaction-response", "http://hl7.org/fhir/bundle-type"), 042 043 HISTORY("history", "http://hl7.org/fhir/bundle-type"), 044 045 SEARCHSET("searchset", "http://hl7.org/fhir/bundle-type"), 046 047 COLLECTION("collection", "http://hl7.org/fhir/bundle-type"), 048 049 050 ; 051 052 /** 053 * Identifier for this Value Set: 054 * http://hl7.org/fhir/vs/address-use 055 */ 056 public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/bundle-type"; 057 058 /** 059 * Name for this Value Set: 060 * AddressUse 061 */ 062 public static final String VALUESET_NAME = "BundleType"; 063 064 private static Map<String, BundleTypeEnum> CODE_TO_ENUM = new HashMap<String, BundleTypeEnum>(); 065 private static Map<String, Map<String, BundleTypeEnum>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, BundleTypeEnum>>(); 066 067 private final String myCode; 068 private final String mySystem; 069 070 static { 071 for (BundleTypeEnum next : BundleTypeEnum.values()) { 072 CODE_TO_ENUM.put(next.getCode(), next); 073 074 if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) { 075 SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, BundleTypeEnum>()); 076 } 077 SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next); 078 } 079 } 080 081 /** 082 * Returns the code associated with this enumerated value 083 */ 084 public String getCode() { 085 return myCode; 086 } 087 088 /** 089 * Returns the code system associated with this enumerated value 090 */ 091 public String getSystem() { 092 return mySystem; 093 } 094 095 /** 096 * Returns the enumerated value associated with this code 097 */ 098 public BundleTypeEnum forCode(String theCode) { 099 BundleTypeEnum retVal = CODE_TO_ENUM.get(theCode); 100 return retVal; 101 } 102 103 /** 104 * Converts codes to their respective enumerated values 105 */ 106 public static final IValueSetEnumBinder<BundleTypeEnum> VALUESET_BINDER = new IValueSetEnumBinder<BundleTypeEnum>() { 107 108 private static final long serialVersionUID = -305725916208867517L; 109 110 @Override 111 public String toCodeString(BundleTypeEnum theEnum) { 112 return theEnum.getCode(); 113 } 114 115 @Override 116 public String toSystemString(BundleTypeEnum theEnum) { 117 return theEnum.getSystem(); 118 } 119 120 @Override 121 public BundleTypeEnum fromCodeString(String theCodeString) { 122 return CODE_TO_ENUM.get(theCodeString); 123 } 124 125 @Override 126 public BundleTypeEnum fromCodeString(String theCodeString, String theSystemString) { 127 Map<String, BundleTypeEnum> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString); 128 if (map == null) { 129 return null; 130 } 131 return map.get(theCodeString); 132 } 133 134 }; 135 136 /** 137 * Constructor 138 */ 139 BundleTypeEnum(String theCode, String theSystem) { 140 myCode = theCode; 141 mySystem = theSystem; 142 } 143 144 145}