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 BindingConformanceEnum {
30  
31  	/**
32  	 * Code Value: <b>required</b>
33  	 *
34  	 * Only codes in the specified set are allowed.  If the binding is extensible, other codes may be used for concepts not covered by the bound set of codes.
35  	 */
36  	REQUIRED("required", "http://hl7.org/fhir/binding-conformance"),
37  	
38  	/**
39  	 * Code Value: <b>preferred</b>
40  	 *
41  	 * For greater interoperability, implementers are strongly encouraged to use the bound set of codes, however alternate codes may be used in derived profiles and implementations if necessary without being considered non-conformant.
42  	 */
43  	PREFERRED("preferred", "http://hl7.org/fhir/binding-conformance"),
44  	
45  	/**
46  	 * Code Value: <b>example</b>
47  	 *
48  	 * The codes in the set are an example to illustrate the meaning of the field. There is no particular preference for its use nor any assertion that the provided values are sufficient to meet implementation needs.
49  	 */
50  	EXAMPLE("example", "http://hl7.org/fhir/binding-conformance"),
51  	
52  	;
53  	
54  	/**
55  	 * Identifier for this Value Set:
56  	 * http://hl7.org/fhir/vs/binding-conformance
57  	 */
58  	public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/binding-conformance";
59  
60  	/**
61  	 * Name for this Value Set:
62  	 * BindingConformance
63  	 */
64  	public static final String VALUESET_NAME = "BindingConformance";
65  
66  	private static Map<String, BindingConformanceEnum> CODE_TO_ENUM = new HashMap<String, BindingConformanceEnum>();
67  	private static Map<String, Map<String, BindingConformanceEnum>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, BindingConformanceEnum>>();
68  	
69  	private final String myCode;
70  	private final String mySystem;
71  	
72  	static {
73  		for (BindingConformanceEnum next : BindingConformanceEnum.values()) {
74  			CODE_TO_ENUM.put(next.getCode(), next);
75  			
76  			if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
77  				SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, BindingConformanceEnum>());
78  			}
79  			SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);			
80  		}
81  	}
82  	
83  	/**
84  	 * Returns the code associated with this enumerated value
85  	 */
86  	public String getCode() {
87  		return myCode;
88  	}
89  	
90  	/**
91  	 * Returns the code system associated with this enumerated value
92  	 */
93  	public String getSystem() {
94  		return mySystem;
95  	}
96  	
97  	/**
98  	 * Returns the enumerated value associated with this code
99  	 */
100 	public BindingConformanceEnum forCode(String theCode) {
101 		BindingConformanceEnum retVal = CODE_TO_ENUM.get(theCode);
102 		return retVal;
103 	}
104 
105 	/**
106 	 * Converts codes to their respective enumerated values
107 	 */
108 	public static final IValueSetEnumBinder<BindingConformanceEnum> VALUESET_BINDER = new IValueSetEnumBinder<BindingConformanceEnum>() {
109 		@Override
110 		public String toCodeString(BindingConformanceEnum theEnum) {
111 			return theEnum.getCode();
112 		}
113 
114 		@Override
115 		public String toSystemString(BindingConformanceEnum theEnum) {
116 			return theEnum.getSystem();
117 		}
118 		
119 		@Override
120 		public BindingConformanceEnum fromCodeString(String theCodeString) {
121 			return CODE_TO_ENUM.get(theCodeString);
122 		}
123 		
124 		@Override
125 		public BindingConformanceEnum fromCodeString(String theCodeString, String theSystemString) {
126 			Map<String, BindingConformanceEnum> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
127 			if (map == null) {
128 				return null;
129 			}
130 			return map.get(theCodeString);
131 		}
132 		
133 	};
134 	
135 	/** 
136 	 * Constructor
137 	 */
138 	BindingConformanceEnum(String theCode, String theSystem) {
139 		myCode = theCode;
140 		mySystem = theSystem;
141 	}
142 
143 	
144 }