View Javadoc
1   package ca.uhn.fhir.rest.api;
2   
3   /*
4    * #%L
5    * HAPI FHIR - Core Library
6    * %%
7    * Copyright (C) 2014 - 2018 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import java.util.HashMap;
24  import java.util.Map;
25  
26  /**
27   * Enum representing the values for the <code>_summary</code> search parameter
28   */
29  public enum SummaryEnum {
30  
31  	/**
32  	 * Return only those elements marked as 'summary' in the base definition of the resource(s)
33  	 */
34  	TRUE("true"),
35  
36  	/**
37  	 * Return only the 'text' element, and any mandatory elements
38  	 */
39  	TEXT("text"),
40  
41  	/**
42  	 * Remove the text element
43  	 */
44  	DATA("data"),
45  
46  	/**
47  	 * Search only: just return a count of the matching resources, without returning the actual matches
48  	 */
49  	COUNT("count"),
50  
51  	/**
52  	 * Return all parts of the resource(s)
53  	 */
54  	FALSE("false");
55  	
56  	private String myCode;
57  	private static Map<String, SummaryEnum> ourCodeToSummary = null;
58  
59  	SummaryEnum(String theCode) {
60  		myCode = theCode;
61  	}
62  
63  	public String getCode() {
64  		return myCode;
65  	}
66  
67  	public static SummaryEnum fromCode(String theCode) {
68  		Map<String, SummaryEnum> c2s = ourCodeToSummary;
69  		if (c2s == null) {
70  			c2s = new HashMap<String, SummaryEnum>();
71  			for (SummaryEnum next : values()) {
72  				c2s.put(next.getCode(), next);
73  			}
74  			ourCodeToSummary = c2s;
75  		}
76  		return c2s.get(theCode);
77  	}
78  	
79  }