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  @CoverageIgnore
31  public enum BundleEntrySearchModeEnum {
32  
33  	MATCH("match", "http://hl7.org/fhir/search-entry-mode"),
34  	INCLUDE("include", "http://hl7.org/fhir/search-entry-mode"),
35  	
36  	;
37  	
38  	/**
39  	 * Identifier for this Value Set:
40  	 * http://hl7.org/fhir/vs/address-use
41  	 */
42  	public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/bundle-entry-status";
43  
44  	/**
45  	 * Name for this Value Set:
46  	 * AddressUse
47  	 */
48  	public static final String VALUESET_NAME = "BundleEntryStatus";
49  
50  	private static Map<String, BundleEntrySearchModeEnum> CODE_TO_ENUM = new HashMap<String, BundleEntrySearchModeEnum>();
51  	private static Map<String, Map<String, BundleEntrySearchModeEnum>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, BundleEntrySearchModeEnum>>();
52  	
53  	private final String myCode;
54  	private final String mySystem;
55  	
56  	static {
57  		for (BundleEntrySearchModeEnum next : BundleEntrySearchModeEnum.values()) {
58  			CODE_TO_ENUM.put(next.getCode(), next);
59  			
60  			if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
61  				SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, BundleEntrySearchModeEnum>());
62  			}
63  			SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);			
64  		}
65  	}
66  	
67  	/**
68  	 * Returns the code associated with this enumerated value
69  	 */
70  	public String getCode() {
71  		return myCode;
72  	}
73  	
74  	/**
75  	 * Returns the code system associated with this enumerated value
76  	 */
77  	public String getSystem() {
78  		return mySystem;
79  	}
80  	
81  	/**
82  	 * Returns the enumerated value associated with this code
83  	 */
84  	public BundleEntrySearchModeEnum forCode(String theCode) {
85  		BundleEntrySearchModeEnum retVal = CODE_TO_ENUM.get(theCode);
86  		return retVal;
87  	}
88  
89  	/**
90  	 * Converts codes to their respective enumerated values
91  	 */
92  	public static final IValueSetEnumBinder<BundleEntrySearchModeEnum> VALUESET_BINDER = new IValueSetEnumBinder<BundleEntrySearchModeEnum>() {
93  
94  		private static final long serialVersionUID = -3836039426814809083L;
95  
96  		@Override
97  		public String toCodeString(BundleEntrySearchModeEnum theEnum) {
98  			return theEnum.getCode();
99  		}
100 
101 		@Override
102 		public String toSystemString(BundleEntrySearchModeEnum theEnum) {
103 			return theEnum.getSystem();
104 		}
105 		
106 		@Override
107 		public BundleEntrySearchModeEnum fromCodeString(String theCodeString) {
108 			return CODE_TO_ENUM.get(theCodeString);
109 		}
110 		
111 		@Override
112 		public BundleEntrySearchModeEnum fromCodeString(String theCodeString, String theSystemString) {
113 			Map<String, BundleEntrySearchModeEnum> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
114 			if (map == null) {
115 				return null;
116 			}
117 			return map.get(theCodeString);
118 		}
119 		
120 	};
121 	
122 	/** 
123 	 * Constructor
124 	 */
125 	BundleEntrySearchModeEnum(String theCode, String theSystem) {
126 		myCode = theCode;
127 		mySystem = theSystem;
128 	}
129 
130 	
131 }