View Javadoc
1   package ca.uhn.fhir.rest.annotation;
2   
3   /*
4    * #%L
5    * HAPI FHIR - Core Library
6    * %%
7    * Copyright (C) 2014 - 2018 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  import java.lang.annotation.*;
23  
24  import org.hl7.fhir.instance.model.api.IBaseResource;
25  
26  import ca.uhn.fhir.rest.client.api.IBasicClient;
27  import ca.uhn.fhir.rest.client.api.IRestfulClient;
28  
29  /**
30   * RESTful method annotation to be used for the FHIR <a href="http://hl7.org/implement/standards/fhir/http.html#read">read</a> and <a
31   * href="http://hl7.org/implement/standards/fhir/http.html#vread">vread</a> method.
32   * 
33   * <p>
34   * If this method has a parameter annotated with the {@link IdParam} annotation and a parameter annotated with the {@link VersionIdParam} annotation, the method will be treated as a vread method. If
35   * the method has only a parameter annotated with the {@link IdParam} annotation, it will be treated as a read operation.
36   * the
37   * </p>
38   * <p>
39   * If you wish for your server to support both read and vread operations, you will need
40   * two methods annotated with this annotation.
41   * </p>
42   */
43  @Retention(RetentionPolicy.RUNTIME)
44  @Target(ElementType.METHOD)
45  public @interface Read {
46  
47  	/**
48  	 * The return type for this method. This generally does not need to be populated for IResourceProvider in a server implementation, but often does need to be populated in
49  	 * client implementations using {@link IBasicClient} or {@link IRestfulClient}, or in plain providers on a server.
50  	 * <p>
51  	 * This value also does not need to be populated if the return type for a method annotated with this annotation is sufficient to determine the type of resource provided. E.g. if the method returns
52  	 * <code>Patient</code> or <code>List&lt;Patient&gt;</code>, the server/client will automatically determine that the Patient resource is the return type, and this value may be left blank.
53  	 * </p>
54  	 */
55  	// NB: Read, Search (maybe others) share this annotation, so update the javadocs everywhere
56  	Class<? extends IBaseResource> type() default IBaseResource.class;
57  
58  	/**
59  	 * If set to true (default is false), this method supports vread operation as well as read
60  	 */
61  	boolean version() default false;
62  
63  }