View Javadoc
1   
2   package ca.uhn.fhir.model.valueset;
3   
4   /*
5    * #%L
6    * HAPI FHIR - Core Library
7    * %%
8    * Copyright (C) 2014 - 2018 University Health Network
9    * %%
10   * Licensed under the Apache License, Version 2.0 (the "License");
11   * you may not use this file except in compliance with the License.
12   * You may obtain a copy of the License at
13   * 
14   *      http://www.apache.org/licenses/LICENSE-2.0
15   * 
16   * Unless required by applicable law or agreed to in writing, software
17   * distributed under the License is distributed on an "AS IS" BASIS,
18   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19   * See the License for the specific language governing permissions and
20   * limitations under the License.
21   * #L%
22   */
23  
24  import java.util.HashMap;
25  import java.util.Map;
26  
27  import ca.uhn.fhir.model.api.IValueSetEnumBinder;
28  import ca.uhn.fhir.util.CoverageIgnore;
29  
30  /**
31   * This Enum is only used to support using the DSTU1 Bundle structure (<code>ca.uhn.fhir.model.api.Bundle</code>)
32   * on a DSTU2 server. It is preferably to use the new DSTU2 Bundle (<code>ca.uhn.fhir.model.dstu2.resource.Bundle</code>)
33   * for this purpose.
34   */
35  @CoverageIgnore
36  public enum BundleEntryTransactionMethodEnum {
37  
38  	GET("GET", "http://hl7.org/fhir/http-verb"),
39  	POST("POST", "http://hl7.org/fhir/http-verb"),
40  	PUT("PUT", "http://hl7.org/fhir/http-verb"),
41  	DELETE("DELETE", "http://hl7.org/fhir/http-verb"),
42  	
43  	;
44  	
45  	/**
46  	 * Identifier for this Value Set:
47  	 * http://hl7.org/fhir/vs/address-use
48  	 */
49  	public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/http-verb";
50  
51  	/**
52  	 * Name for this Value Set:
53  	 * AddressUse
54  	 */
55  	public static final String VALUESET_NAME = "BundleEntryStatus";
56  
57  	private static Map<String, BundleEntryTransactionMethodEnum> CODE_TO_ENUM = new HashMap<String, BundleEntryTransactionMethodEnum>();
58  	private static Map<String, Map<String, BundleEntryTransactionMethodEnum>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, BundleEntryTransactionMethodEnum>>();
59  	
60  	private final String myCode;
61  	private final String mySystem;
62  	
63  	static {
64  		for (BundleEntryTransactionMethodEnum next : BundleEntryTransactionMethodEnum.values()) {
65  			CODE_TO_ENUM.put(next.getCode(), next);
66  			
67  			if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
68  				SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, BundleEntryTransactionMethodEnum>());
69  			}
70  			SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);			
71  		}
72  	}
73  	
74  	/**
75  	 * Returns the code associated with this enumerated value
76  	 */
77  	public String getCode() {
78  		return myCode;
79  	}
80  	
81  	/**
82  	 * Returns the code system associated with this enumerated value
83  	 */
84  	public String getSystem() {
85  		return mySystem;
86  	}
87  	
88  	/**
89  	 * Returns the enumerated value associated with this code
90  	 */
91  	public BundleEntryTransactionMethodEnum forCode(String theCode) {
92  		BundleEntryTransactionMethodEnum retVal = CODE_TO_ENUM.get(theCode);
93  		return retVal;
94  	}
95  
96  	/**
97  	 * Converts codes to their respective enumerated values
98  	 */
99  	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 }