001/*-
002 * #%L
003 * Smile CDR - CDR
004 * %%
005 * Copyright (C) 2016 - 2024 Smile CDR, Inc.
006 * %%
007 * All rights reserved.
008 * #L%
009 */
010package ca.cdr.api.fhirgw.model;
011
012import jakarta.annotation.Nonnull;
013import org.hl7.fhir.instance.model.api.IBaseResource;
014
015import java.util.Collections;
016import java.util.List;
017
018/**
019 * This class represents the response to a FHIR Gateway Search request
020 */
021public class SearchResponse extends BaseResponse<SearchResponse> {
022
023        @Nonnull
024        private List<IBaseResource> mySearchResults;
025
026        /**
027         * Constructor - Create an empty object
028         */
029        public SearchResponse() {
030                super();
031                mySearchResults = Collections.emptyList();
032        }
033
034        /**
035         * Copy constructor - Creates a shallow copy only
036         */
037        public SearchResponse(SearchResponse theSearchResponse) {
038                super(theSearchResponse);
039                mySearchResults = theSearchResponse.getSearchResults();
040        }
041
042        /**
043         * Provides the list of resources that were responded by the gateway target server.
044         * Interceptors may modify this list, modify entries in this list, or even add/remove entries
045         * from the list.
046         */
047        @Nonnull
048        public List<IBaseResource> getSearchResults() {
049                return mySearchResults;
050        }
051
052        /**
053         * Provides the list of resources that were responded by the gateway target server.
054         * Interceptors may modify this list, modify entries in this list, or even add/remove entries
055         * from the list.
056         */
057        public void setSearchResults(@Nonnull List<IBaseResource> theSearchResults) {
058                mySearchResults = theSearchResults;
059        }
060
061        /**
062         * Create a clone of this object using a <b>shallow copy only</b>. Values
063         * are copied by reference only, so things like Resources should only be
064         * modified if you are sure that the changes won't affect the value
065         * stored in cache.
066         */
067        @Override
068        public SearchResponse clone() {
069                return new SearchResponse(this);
070        }
071}