001/*
002 * #%L
003 * HAPI FHIR - Core Library
004 * %%
005 * Copyright (C) 2014 - 2024 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 ca.uhn.fhir.model.api.IValueSetEnumBinder;
023import ca.uhn.fhir.util.CoverageIgnore;
024
025import java.util.HashMap;
026import java.util.Map;
027
028@CoverageIgnore
029public enum BundleEntrySearchModeEnum {
030        MATCH("match", "http://hl7.org/fhir/search-entry-mode"),
031        INCLUDE("include", "http://hl7.org/fhir/search-entry-mode"),
032        ;
033
034        /**
035         * Identifier for this Value Set:
036         * http://hl7.org/fhir/vs/address-use
037         */
038        public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/bundle-entry-status";
039
040        /**
041         * Name for this Value Set:
042         * AddressUse
043         */
044        public static final String VALUESET_NAME = "BundleEntryStatus";
045
046        private static Map<String, BundleEntrySearchModeEnum> CODE_TO_ENUM =
047                        new HashMap<String, BundleEntrySearchModeEnum>();
048        private static Map<String, Map<String, BundleEntrySearchModeEnum>> SYSTEM_TO_CODE_TO_ENUM =
049                        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 =
091                        new IValueSetEnumBinder<BundleEntrySearchModeEnum>() {
092
093                                private static final long serialVersionUID = -3836039426814809083L;
094
095                                @Override
096                                public String toCodeString(BundleEntrySearchModeEnum theEnum) {
097                                        return theEnum.getCode();
098                                }
099
100                                @Override
101                                public String toSystemString(BundleEntrySearchModeEnum theEnum) {
102                                        return theEnum.getSystem();
103                                }
104
105                                @Override
106                                public BundleEntrySearchModeEnum fromCodeString(String theCodeString) {
107                                        return CODE_TO_ENUM.get(theCodeString);
108                                }
109
110                                @Override
111                                public BundleEntrySearchModeEnum fromCodeString(String theCodeString, String theSystemString) {
112                                        Map<String, BundleEntrySearchModeEnum> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
113                                        if (map == null) {
114                                                return null;
115                                        }
116                                        return map.get(theCodeString);
117                                }
118                        };
119
120        /**
121         * Constructor
122         */
123        BundleEntrySearchModeEnum(String theCode, String theSystem) {
124                myCode = theCode;
125                mySystem = theSystem;
126        }
127}