001
002package ca.uhn.fhir.model.valueset;
003
004/*
005 * #%L
006 * HAPI FHIR - Core Library
007 * %%
008 * Copyright (C) 2014 - 2021 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/**
031 * This Enum is only used to support using the DSTU1 Bundle structure (<code>ca.uhn.fhir.model.api.Bundle</code>)
032 * on a DSTU2 server. It is preferably to use the new DSTU2 Bundle (<code>ca.uhn.fhir.model.dstu2.resource.Bundle</code>)
033 * for this purpose.
034 */
035@CoverageIgnore
036public enum BundleEntryTransactionMethodEnum {
037
038        GET("GET", "http://hl7.org/fhir/http-verb"),
039        POST("POST", "http://hl7.org/fhir/http-verb"),
040        PUT("PUT", "http://hl7.org/fhir/http-verb"),
041        DELETE("DELETE", "http://hl7.org/fhir/http-verb"),
042        
043        ;
044        
045        /**
046         * Identifier for this Value Set:
047         * http://hl7.org/fhir/vs/address-use
048         */
049        public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/http-verb";
050
051        /**
052         * Name for this Value Set:
053         * AddressUse
054         */
055        public static final String VALUESET_NAME = "BundleEntryStatus";
056
057        private static Map<String, BundleEntryTransactionMethodEnum> CODE_TO_ENUM = new HashMap<String, BundleEntryTransactionMethodEnum>();
058        private static Map<String, Map<String, BundleEntryTransactionMethodEnum>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, BundleEntryTransactionMethodEnum>>();
059        
060        private final String myCode;
061        private final String mySystem;
062        
063        static {
064                for (BundleEntryTransactionMethodEnum next : BundleEntryTransactionMethodEnum.values()) {
065                        CODE_TO_ENUM.put(next.getCode(), next);
066                        
067                        if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
068                                SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, BundleEntryTransactionMethodEnum>());
069                        }
070                        SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);                 
071                }
072        }
073        
074        /**
075         * Returns the code associated with this enumerated value
076         */
077        public String getCode() {
078                return myCode;
079        }
080        
081        /**
082         * Returns the code system associated with this enumerated value
083         */
084        public String getSystem() {
085                return mySystem;
086        }
087        
088        /**
089         * Returns the enumerated value associated with this code
090         */
091        public BundleEntryTransactionMethodEnum forCode(String theCode) {
092                BundleEntryTransactionMethodEnum retVal = CODE_TO_ENUM.get(theCode);
093                return retVal;
094        }
095
096        /**
097         * Converts codes to their respective enumerated values
098         */
099        public static final IValueSetEnumBinder<BundleEntryTransactionMethodEnum> VALUESET_BINDER = new IValueSetEnumBinder<BundleEntryTransactionMethodEnum>() {
100
101                private static final long serialVersionUID = 7569681479045998433L;
102
103                @Override
104                public String toCodeString(BundleEntryTransactionMethodEnum theEnum) {
105                        return theEnum.getCode();
106                }
107
108                @Override
109                public String toSystemString(BundleEntryTransactionMethodEnum theEnum) {
110                        return theEnum.getSystem();
111                }
112                
113                @Override
114                public BundleEntryTransactionMethodEnum fromCodeString(String theCodeString) {
115                        return CODE_TO_ENUM.get(theCodeString);
116                }
117                
118                @Override
119                public BundleEntryTransactionMethodEnum fromCodeString(String theCodeString, String theSystemString) {
120                        Map<String, BundleEntryTransactionMethodEnum> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
121                        if (map == null) {
122                                return null;
123                        }
124                        return map.get(theCodeString);
125                }
126                
127        };
128        
129        /** 
130         * Constructor
131         */
132        BundleEntryTransactionMethodEnum(String theCode, String theSystem) {
133                myCode = theCode;
134                mySystem = theSystem;
135        }
136
137        
138}