001/*-
002 * #%L
003 * HAPI FHIR Storage api
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.storage.interceptor;
021
022/**
023 * This object is used as a return type for interceptor hook methods implementing the
024 * {@link ca.uhn.fhir.interceptor.api.Pointcut#STORAGE_PRE_AUTO_CREATE_PLACEHOLDER_REFERENCE}
025 * pointcut.
026 *
027 * @since 8.4.0
028 * @see #doNotCreateTarget()
029 * @see #proceed()
030 */
031public class AutoCreatePlaceholderReferenceTargetResponse {
032
033        private boolean myDoNotCreateTarget;
034
035        /**
036         * Use the static factory methods to create this object
037         */
038        private AutoCreatePlaceholderReferenceTargetResponse(boolean theDoNotCreateTarget) {
039                myDoNotCreateTarget = theDoNotCreateTarget;
040        }
041
042        /**
043         * Should the placeholder resource not be created?
044         */
045        public boolean isDoNotCreateTarget() {
046                return myDoNotCreateTarget;
047        }
048
049        /**
050         * Create response: The placeholder reference target should <b>not</b> be created.
051         * Under most circumstances this will cause the operation to be aborted due to
052         * the invalid reference.
053         */
054        public static AutoCreatePlaceholderReferenceTargetResponse doNotCreateTarget() {
055                return new AutoCreatePlaceholderReferenceTargetResponse(true);
056        }
057
058        /**
059         * Create response: The placeholder reference target should be created.
060         */
061        public static AutoCreatePlaceholderReferenceTargetResponse proceed() {
062                return new AutoCreatePlaceholderReferenceTargetResponse(false);
063        }
064}