001/*-
002 * #%L
003 * HAPI FHIR - Server Framework
004 * %%
005 * Copyright (C) 2014 - 2025 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.api.server;
021
022import org.hl7.fhir.instance.model.api.IBaseResource;
023
024/**
025 * The body and status code of a FHIR response.
026 * Both the status code and response resource are mutable.
027 * The resource may be replaced entirely.
028 * @see ca.uhn.fhir.rest.server.interceptor.IServerInterceptor
029 */
030public class ResponseDetails {
031
032        private IBaseResource myResponseResource;
033        private int myResponseCode;
034
035        /**
036         * empty constructor left for backwards compatibility.
037         * @deprecated Use the two-arg constructor to initialize the fields.
038         */
039        @Deprecated
040        public ResponseDetails() {
041                // empty
042        }
043
044        public ResponseDetails(int theStatusCode, IBaseResource theResponseResource) {
045                myResponseResource = theResponseResource;
046                myResponseCode = theStatusCode;
047        }
048
049        /**
050         * Constructor
051         */
052        public ResponseDetails(IBaseResource theResponseResource) {
053                setResponseResource(theResponseResource);
054        }
055
056        public int getResponseCode() {
057                return myResponseCode;
058        }
059
060        public void setResponseCode(int theResponseCode) {
061                myResponseCode = theResponseCode;
062        }
063
064        /**
065         * Get the resource which will be returned to the client
066         */
067        public IBaseResource getResponseResource() {
068                return myResponseResource;
069        }
070
071        /**
072         * Set the resource which will be returned to the client
073         */
074        public void setResponseResource(IBaseResource theResponseResource) {
075                myResponseResource = theResponseResource;
076        }
077}