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 BundleEntrySearchModeEnum {
030
031        MATCH("match", "http://hl7.org/fhir/search-entry-mode"),
032        INCLUDE("include", "http://hl7.org/fhir/search-entry-mode"),
033        
034        ;
035        
036        /**
037         * Identifier for this Value Set:
038         * http://hl7.org/fhir/vs/address-use
039         */
040        public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/bundle-entry-status";
041
042        /**
043         * Name for this Value Set:
044         * AddressUse
045         */
046        public static final String VALUESET_NAME = "BundleEntryStatus";
047
048        private static Map<String, BundleEntrySearchModeEnum> CODE_TO_ENUM = new HashMap<String, BundleEntrySearchModeEnum>();
049        private static Map<String, Map<String, BundleEntrySearchModeEnum>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, BundleEntrySearchModeEnum>>();
050        
051        private final String myCode;
052        private final String mySystem;
053        
054        static {
055                for (BundleEntrySearchModeEnum next : BundleEntrySearchModeEnum.values()) {
056                        CODE_TO_ENUM.put(next.getCode(), next);
057                        
058                        if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
059                                SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, BundleEntrySearchModeEnum>());
060                        }
061                        SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);                 
062                }
063        }
064        
065        /**
066         * Returns the code associated with this enumerated value
067         */
068        public String getCode() {
069                return myCode;
070        }
071        
072        /**
073         * Returns the code system associated with this enumerated value
074         */
075        public String getSystem() {
076                return mySystem;
077        }
078        
079        /**
080         * Returns the enumerated value associated with this code
081         */
082        public BundleEntrySearchModeEnum forCode(String theCode) {
083                BundleEntrySearchModeEnum retVal = CODE_TO_ENUM.get(theCode);
084                return retVal;
085        }
086
087        /**
088         * Converts codes to their respective enumerated values
089         */
090        public static final IValueSetEnumBinder<BundleEntrySearchModeEnum> VALUESET_BINDER = new IValueSetEnumBinder<BundleEntrySearchModeEnum>() {
091
092                private static final long serialVersionUID = -3836039426814809083L;
093
094                @Override
095                public String toCodeString(BundleEntrySearchModeEnum theEnum) {
096                        return theEnum.getCode();
097                }
098
099                @Override
100                public String toSystemString(BundleEntrySearchModeEnum theEnum) {
101                        return theEnum.getSystem();
102                }
103                
104                @Override
105                public BundleEntrySearchModeEnum fromCodeString(String theCodeString) {
106                        return CODE_TO_ENUM.get(theCodeString);
107                }
108                
109                @Override
110                public BundleEntrySearchModeEnum fromCodeString(String theCodeString, String theSystemString) {
111                        Map<String, BundleEntrySearchModeEnum> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
112                        if (map == null) {
113                                return null;
114                        }
115                        return map.get(theCodeString);
116                }
117                
118        };
119        
120        /** 
121         * Constructor
122         */
123        BundleEntrySearchModeEnum(String theCode, String theSystem) {
124                myCode = theCode;
125                mySystem = theSystem;
126        }
127
128        
129}