View Javadoc
1   
2   package ca.uhn.fhir.model.dstu.valueset;
3   
4   /*
5    * #%L
6    * HAPI FHIR - Core Library
7    * %%
8    * Copyright (C) 2014 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  
29  public enum ConformanceEventModeEnum {
30  
31  	/**
32  	 * Code Value: <b>sender</b>
33  	 *
34  	 * The application sends requests and receives responses.
35  	 */
36  	SENDER("sender", "http://hl7.org/fhir/message-conformance-event-mode"),
37  	
38  	/**
39  	 * Code Value: <b>receiver</b>
40  	 *
41  	 * The application receives requests and sends responses.
42  	 */
43  	RECEIVER("receiver", "http://hl7.org/fhir/message-conformance-event-mode"),
44  	
45  	;
46  	
47  	/**
48  	 * Identifier for this Value Set:
49  	 * http://hl7.org/fhir/vs/message-conformance-event-mode
50  	 */
51  	public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/message-conformance-event-mode";
52  
53  	/**
54  	 * Name for this Value Set:
55  	 * ConformanceEventMode
56  	 */
57  	public static final String VALUESET_NAME = "ConformanceEventMode";
58  
59  	private static Map<String, ConformanceEventModeEnum> CODE_TO_ENUM = new HashMap<String, ConformanceEventModeEnum>();
60  	private static Map<String, Map<String, ConformanceEventModeEnum>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, ConformanceEventModeEnum>>();
61  	
62  	private final String myCode;
63  	private final String mySystem;
64  	
65  	static {
66  		for (ConformanceEventModeEnum next : ConformanceEventModeEnum.values()) {
67  			CODE_TO_ENUM.put(next.getCode(), next);
68  			
69  			if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
70  				SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, ConformanceEventModeEnum>());
71  			}
72  			SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);			
73  		}
74  	}
75  	
76  	/**
77  	 * Returns the code associated with this enumerated value
78  	 */
79  	public String getCode() {
80  		return myCode;
81  	}
82  	
83  	/**
84  	 * Returns the code system associated with this enumerated value
85  	 */
86  	public String getSystem() {
87  		return mySystem;
88  	}
89  	
90  	/**
91  	 * Returns the enumerated value associated with this code
92  	 */
93  	public ConformanceEventModeEnum forCode(String theCode) {
94  		ConformanceEventModeEnum retVal = CODE_TO_ENUM.get(theCode);
95  		return retVal;
96  	}
97  
98  	/**
99  	 * Converts codes to their respective enumerated values
100 	 */
101 	public static final IValueSetEnumBinder<ConformanceEventModeEnum> VALUESET_BINDER = new IValueSetEnumBinder<ConformanceEventModeEnum>() {
102 		@Override
103 		public String toCodeString(ConformanceEventModeEnum theEnum) {
104 			return theEnum.getCode();
105 		}
106 
107 		@Override
108 		public String toSystemString(ConformanceEventModeEnum theEnum) {
109 			return theEnum.getSystem();
110 		}
111 		
112 		@Override
113 		public ConformanceEventModeEnum fromCodeString(String theCodeString) {
114 			return CODE_TO_ENUM.get(theCodeString);
115 		}
116 		
117 		@Override
118 		public ConformanceEventModeEnum fromCodeString(String theCodeString, String theSystemString) {
119 			Map<String, ConformanceEventModeEnum> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
120 			if (map == null) {
121 				return null;
122 			}
123 			return map.get(theCodeString);
124 		}
125 		
126 	};
127 	
128 	/** 
129 	 * Constructor
130 	 */
131 	ConformanceEventModeEnum(String theCode, String theSystem) {
132 		myCode = theCode;
133 		mySystem = theSystem;
134 	}
135 
136 	
137 }