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