001/*- 002 * #%L 003 * HAPI FHIR - Core Library 004 * %% 005 * Copyright (C) 2014 - 2023 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.rest.param; 021 022import java.util.*; 023 024/** 025 * Comparator/qualifier for values used in REST params, such as {@link DateParam}, {@link NumberParam}, and 026 * {@link QuantityParam} 027 * 028 * @since 1.5 029 */ 030public enum ParamPrefixEnum { 031 032 /** 033 * Code Value: <b>eq</b> 034 * 035 * The actual value is equal to the given value 036 */ 037 APPROXIMATE("ap"), 038 039 /** 040 * Code Value: <b>eb</b> 041 * 042 * 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 043 */ 044 ENDS_BEFORE("eb"), 045 046 /** 047 * Code Value: <b>eq</b> 048 * 049 * The actual value is equal to the given value 050 */ 051 EQUAL("eq"), 052 053 /** 054 * Code Value: <b>gt</b> 055 * 056 * The actual value is greater than the given value. 057 */ 058 GREATERTHAN("gt"), 059 060 /** 061 * Code Value: <b>ge</b> 062 * 063 * The actual value is greater than or equal to the given value. 064 */ 065 GREATERTHAN_OR_EQUALS("ge"), 066 067 /** 068 * Code Value: <b>lt</b> 069 * 070 * The actual value is less than the given value. 071 */ 072 LESSTHAN("lt"), 073 074 /** 075 * Code Value: <b>le</b> 076 * 077 * The actual value is less than or equal to the given value. 078 */ 079 LESSTHAN_OR_EQUALS("le"), 080 081 /** 082 * Code Value: <b>ne</b> 083 * 084 * The actual value is not equal to the given value 085 */ 086 NOT_EQUAL("ne"), 087 088 /** 089 * Code Value: <b>sa</b> 090 * 091 * 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 092 */ 093 STARTS_AFTER("sa"); 094 095 private static final Map<String, ParamPrefixEnum> VALUE_TO_PREFIX; 096 097 static { 098 HashMap<String, ParamPrefixEnum> valueToPrefix = new HashMap<String, ParamPrefixEnum>(); 099 for (ParamPrefixEnum next : values()) { 100 valueToPrefix.put(next.getValue(), next); 101 } 102 103 VALUE_TO_PREFIX = Collections.unmodifiableMap(valueToPrefix); 104 } 105 106 private final String myValue; 107 108 private ParamPrefixEnum(String theValue) { 109 myValue = theValue; 110 } 111 112 /** 113 * Returns the value, e.g. <code>lt</code> or <code>eq</code> 114 */ 115 public String getValue() { 116 return myValue; 117 } 118 119 /** 120 * Returns the prefix associated with a given DSTU2+ value (e.g. <code>lt</code> or <code>eq</code>) 121 * 122 * @param theValue 123 * e.g. <code><</code> or <code>~</code> 124 * @return The prefix, or <code>null</code> if no prefix matches the value 125 */ 126 public static ParamPrefixEnum forValue(String theValue) { 127 return VALUE_TO_PREFIX.get(theValue); 128 } 129}