001package ca.uhn.fhir.rest.api;
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 java.util.HashMap;
024import java.util.Map;
025
026/**
027 * Enum representing the values for the <code>_summary</code> search parameter
028 */
029public enum SummaryEnum {
030
031        /**
032         * Search only: just return a count of the matching resources, without returning the actual matches
033         */
034        COUNT("count"),
035
036        /**
037         * Return only the 'text' element, and any mandatory elements
038         */
039        TEXT("text"),
040
041        /**
042         * Remove the text element
043         */
044        DATA("data"),
045
046        /**
047         * Return only those elements marked as 'summary' in the base definition of the resource(s)
048         */
049        TRUE("true"),
050
051        /**
052         * Return all parts of the resource(s)
053         */
054        FALSE("false");
055        
056        private String myCode;
057        private static Map<String, SummaryEnum> ourCodeToSummary = null;
058
059        SummaryEnum(String theCode) {
060                myCode = theCode;
061        }
062
063        public String getCode() {
064                return myCode;
065        }
066
067        public static SummaryEnum fromCode(String theCode) {
068                Map<String, SummaryEnum> c2s = ourCodeToSummary;
069                if (c2s == null) {
070                        c2s = new HashMap<>();
071                        for (SummaryEnum next : values()) {
072                                c2s.put(next.getCode(), next);
073                        }
074                        ourCodeToSummary = c2s;
075                }
076                return c2s.get(theCode);
077        }
078        
079}