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