View Javadoc
1   package ca.uhn.fhir.rest.param;
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.*;
24  
25  /**
26   * Comparator/qualifier for values used in REST params, such as {@link DateParam}, {@link NumberParam}, and
27   * {@link QuantityParam}
28   * 
29   * @since 1.5
30   */
31  public enum ParamPrefixEnum {
32  
33  	/**
34  	 * Code Value: <b>eq</b>
35  	 *
36  	 * The actual value is equal to the given value
37  	 */
38  	APPROXIMATE("ap"),
39  
40  	/**
41  	 * Code Value: <b>eb</b>
42  	 *
43  	 * The range of the search value does overlap not with the range of the target value, and the range above the search value contains the range of the target value
44  	 */
45  	ENDS_BEFORE("eb"),
46  
47  	/**
48  	 * Code Value: <b>eq</b>
49  	 *
50  	 * The actual value is equal to the given value
51  	 */
52  	EQUAL("eq"),
53  
54  	/**
55  	 * Code Value: <b>gt</b>
56  	 *
57  	 * The actual value is greater than the given value.
58  	 */
59  	GREATERTHAN("gt"),
60  
61  	/**
62  	 * Code Value: <b>ge</b>
63  	 *
64  	 * The actual value is greater than or equal to the given value.
65  	 */
66  	GREATERTHAN_OR_EQUALS("ge"),
67  
68  	/**
69  	 * Code Value: <b>lt</b>
70  	 *
71  	 * The actual value is less than the given value.
72  	 */
73  	LESSTHAN("lt"),
74  
75  	/**
76  	 * Code Value: <b>le</b>
77  	 *
78  	 * The actual value is less than or equal to the given value.
79  	 */
80  	LESSTHAN_OR_EQUALS("le"), 
81  	
82  	/**
83  	 * Code Value: <b>ne</b>
84  	 *
85  	 * The actual value is not equal to the given value
86  	 */
87  	NOT_EQUAL("ne"),
88  	
89  	/**
90  	 * Code Value: <b>sa</b>
91  	 *
92  	 * The range of the search value does not overlap with the range of the target value, and the range below the search value contains the range of the target value
93  	 */
94  	STARTS_AFTER("sa");
95  	
96  	private static final Map<String, ParamPrefixEnum> VALUE_TO_PREFIX;
97  
98  	static {
99  		HashMap<String, ParamPrefixEnum> valueToPrefix = new HashMap<String, ParamPrefixEnum>();
100 		for (ParamPrefixEnum next : values()) {
101 			valueToPrefix.put(next.getValue(), next);
102 		}
103 
104 		VALUE_TO_PREFIX = Collections.unmodifiableMap(valueToPrefix);
105 	}
106 
107 	private final String myValue;
108 
109 	private ParamPrefixEnum(String theValue) {
110 		myValue = theValue;
111 	}
112 
113 	/**
114 	 * Returns the value, e.g. <code>lt</code> or <code>eq</code>
115 	 */
116 	public String getValue() {
117 		return myValue;
118 	}
119 
120 	/**
121 	 * Returns the prefix associated with a given DSTU2+ value (e.g. <code>lt</code> or <code>eq</code>)
122 	 * 
123 	 * @param theValue
124 	 *           e.g. <code>&lt;</code> or <code>~</code>
125 	 * @return The prefix, or <code>null</code> if no prefix matches the value
126 	 */
127 	public static ParamPrefixEnum forValue(String theValue) {
128 		return VALUE_TO_PREFIX.get(theValue);
129 	}
130 }