001package ca.uhn.fhir.jpa.validation;
002
003/*-
004 * #%L
005 * HAPI FHIR Storage api
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 org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy;
024import org.thymeleaf.util.Validate;
025
026import javax.annotation.Nonnull;
027
028public class ValidationSettings {
029
030        private ReferenceValidationPolicy myLocalReferenceValidationDefaultPolicy = ReferenceValidationPolicy.IGNORE;
031
032        /**
033         * Supplies a default policy for validating local references. Default is {@literal IResourceValidator.ReferenceValidationPolicy.IGNORE}.
034         * <p>
035         * Note that this setting can have a measurable impact on validation performance, as it will cause reference targets
036         * to be resolved during validation. In other words, if a resource has a reference to (for example) "Patient/123", the
037         * resource with that ID will be loaded from the database during validation.
038         * </p>
039         *
040         * @since 5.1.0
041         */
042        @Nonnull
043        public ReferenceValidationPolicy getLocalReferenceValidationDefaultPolicy() {
044                return myLocalReferenceValidationDefaultPolicy;
045        }
046
047        /**
048         * Supplies a default policy for validating local references. Default is {@literal IResourceValidator.ReferenceValidationPolicy.IGNORE}.
049         * <p>
050         * Note that this setting can have a measurable impact on validation performance, as it will cause reference targets
051         * to be resolved during validation. In other words, if a resource has a reference to (for example) "Patient/123", the
052         * resource with that ID will be loaded from the database during validation.
053         * </p>
054         *
055         * @since 5.1.0
056         */
057        public void setLocalReferenceValidationDefaultPolicy(@Nonnull ReferenceValidationPolicy theLocalReferenceValidationDefaultPolicy) {
058                Validate.notNull(theLocalReferenceValidationDefaultPolicy, "theLocalReferenceValidationDefaultPolicy must not be null");
059                myLocalReferenceValidationDefaultPolicy = theLocalReferenceValidationDefaultPolicy;
060        }
061}