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