001package ca.uhn.fhir.rest.param;
002
003/*
004 * #%L
005 * HAPI FHIR - Core Library
006 * %%
007 * Copyright (C) 2014 - 2022 Smile CDR, Inc.
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import ca.uhn.fhir.rest.api.Constants;
024
025import java.util.HashMap;
026import java.util.Map;
027
028/**
029 * Modifiers for {@link TokenParam}
030 */
031public enum TokenParamModifier {
032        /** 
033         * :above
034         */
035        ABOVE(":above"),
036        
037        /** 
038         * :above
039         */
040        BELOW(":below"),
041        
042        /** 
043         * :in
044         */
045        IN(":in"),
046        
047        /** 
048         * :not
049         */
050        NOT(":not"),
051        
052        /** 
053         * :not-in
054         */
055        NOT_IN(":not-in"),
056        
057        /** 
058         * :text
059         */
060        TEXT(Constants.PARAMQUALIFIER_TOKEN_TEXT),
061
062        /**
063         * :of-type
064         */
065        OF_TYPE(Constants.PARAMQUALIFIER_TOKEN_OF_TYPE);
066
067        private static final Map<String, TokenParamModifier> VALUE_TO_ENUM;
068
069        static {
070                Map<String, TokenParamModifier> valueToEnum = new HashMap<String, TokenParamModifier>();
071                for (TokenParamModifier next : values()) {
072                        valueToEnum.put(next.getValue(), next);
073                }
074                VALUE_TO_ENUM = valueToEnum;
075        }
076        private final String myValue;
077
078        private TokenParamModifier(String theValue) {
079                myValue = theValue;
080        }
081        
082        public String getValue() {
083                return myValue;
084        }
085
086        /**
087         * The modifier without the :
088         * @return the string after the leading :
089         */
090        public String getBareModifier() {
091                return myValue.substring(1);
092        }
093
094        public static TokenParamModifier forValue(String theValue) {
095                return VALUE_TO_ENUM.get(theValue);
096        }
097
098}