001/*-
002 * #%L
003 * HAPI FHIR - Core Library
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.util.bundle;
021
022import ca.uhn.fhir.rest.api.RequestTypeEnum;
023import org.hl7.fhir.instance.model.api.IBaseResource;
024
025public class BundleEntryParts {
026        protected RequestTypeEnum myRequestType;
027        protected IBaseResource myResource;
028        protected String myUrl;
029        protected String myConditionalUrl;
030        protected String myFullUrl;
031        protected RequestTypeEnum myMethod;
032
033        /**
034         * Constructor
035         */
036        public BundleEntryParts(
037                        String theFullUrl,
038                        RequestTypeEnum theRequestType,
039                        String theUrl,
040                        IBaseResource theResource,
041                        String theConditionalUrl,
042                        RequestTypeEnum theMethod) {
043                super();
044                myFullUrl = theFullUrl;
045                myRequestType = theRequestType;
046                myUrl = theUrl;
047                myResource = theResource;
048                myConditionalUrl = theConditionalUrl;
049                myMethod = theMethod;
050        }
051
052        /**
053         * Copy Constructor
054         */
055        public BundleEntryParts(BundleEntryParts theBundleEntryParts) {
056                this(
057                                theBundleEntryParts.getFullUrl(),
058                                theBundleEntryParts.getRequestType(),
059                                theBundleEntryParts.getUrl(),
060                                theBundleEntryParts.getResource(),
061                                theBundleEntryParts.getConditionalUrl(),
062                                theBundleEntryParts.getMethod());
063        }
064
065        /**
066         * Returns the <code>Bundle.entry.fulUrl</code> value
067         */
068        public String getFullUrl() {
069                return myFullUrl;
070        }
071
072        public RequestTypeEnum getRequestType() {
073                return myRequestType;
074        }
075
076        public IBaseResource getResource() {
077                return myResource;
078        }
079
080        /**
081         * Returns the conditional URL associated with this request, if any.
082         * <ul>
083         * <li>
084         * If the {@link #getMethod() method} is <code>PUT</code>, <code>PATCH</code>, or
085         * <code>DELETE</code>, and the {@link #getUrl() request URL}
086         * contains <code>'?'</code>, returns the {@link #getUrl() request URL}
087         * </li>
088         * <li>
089         * If the {@link #getMethod() method} is <code>POST</code>, and the
090         * <code>Bundle.entry.request.ifNoneExist</code>
091         * contains <code>'?'</code>, returns the <codd>ifNoneExist</codd>
092         * value.
093         * </li>
094         * </ul>
095         * Returns the <code>Bundle.entry.request.url</code> value
096         */
097        public String getConditionalUrl() {
098                return myConditionalUrl;
099        }
100
101        /**
102         * Returns the <code>Bundle.entry.request.url</code> value
103         */
104        public String getUrl() {
105                return myUrl;
106        }
107
108        public RequestTypeEnum getMethod() {
109                return myMethod;
110        }
111}