001package ca.uhn.fhir.rest.annotation;
002
003/*
004 * #%L
005 * HAPI FHIR - Core Library
006 * %%
007 * Copyright (C) 2014 - 2021 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 */
022import java.lang.annotation.*;
023
024import org.hl7.fhir.instance.model.api.IBaseResource;
025
026import ca.uhn.fhir.rest.api.ValidationModeEnum;
027
028/**
029 * RESTful method annotation to be used for the FHIR
030 * <a href="http://hl7.org/implement/standards/fhir/http.html#validate">validate</a> method.
031 * 
032 * <p>
033 * Validate is used to accept a resource, and test whether it would be acceptable for
034 * storing (e.g. using an update or create method)  
035 * </p>
036 * <p>
037 * <b>FHIR Version Note:</b> The validate operation was defined as a type operation in DSTU1
038 * using a URL syntax like <code>http://example.com/Patient/_validate</code>. In DSTU2, validation
039 * has been switched to being an extended operation using a URL syntax like 
040 * <code>http://example.com/Patient/$validate</code>, with a n 
041 * </p>
042 */
043@Retention(RetentionPolicy.RUNTIME)
044@Target(value=ElementType.METHOD)
045public @interface Validate {
046
047        /**
048         * The return type for this method. This generally does not need
049         * to be populated for a server implementation (using an IResourceProvider, 
050         * since resource providers will return only one resource type per class, 
051         * but generally does need to be populated for client implementations. 
052         */
053        // NB: Read, Search (maybe others) share this annotation, so update the javadocs everywhere
054        Class<? extends IBaseResource> type() default IBaseResource.class;
055
056        /**
057         * This method allows the return type for this method to be specified in a
058         * non-type-specific way, using the text name of the resource, e.g. "Patient".
059         *
060         * This attribute should be populate, or {@link #type()} should be, but not both.
061         *
062         * @since 5.4.0
063         */
064        String typeName() default "";
065
066        /**
067         * Validation mode parameter annotation for the validation mode parameter (only supported
068         * in FHIR DSTU2+). Parameter must be of type {@link ValidationModeEnum}.
069         */
070        @Retention(RetentionPolicy.RUNTIME)
071        @Target(value=ElementType.PARAMETER)
072        @interface Mode {
073                // nothing
074        }
075        
076        /**
077         * Validation mode parameter annotation for the validation URI parameter (only supported
078         * in FHIR DSTU2+). Parameter must be of type {@link String}.
079         */
080        @Retention(RetentionPolicy.RUNTIME)
081        @Target(value=ElementType.PARAMETER)
082        @interface Profile {
083                // nothing
084        }
085
086}