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  
23  import java.lang.annotation.ElementType;
24  import java.lang.annotation.Retention;
25  import java.lang.annotation.RetentionPolicy;
26  import java.lang.annotation.Target;
27  
28  import org.hl7.fhir.instance.model.api.IBase;
29  
30  import ca.uhn.fhir.model.primitive.StringDt;
31  import ca.uhn.fhir.rest.param.StringParam;
32  
33  /**
34   */
35  @Retention(RetentionPolicy.RUNTIME)
36  @Target(value=ElementType.PARAMETER)
37  public @interface OperationParam {
38  
39  	/**
40  	 * Value for {@link OperationParam#max()} indicating no maximum
41  	 */
42  	final int MAX_UNLIMITED = -1;
43  
44  
45  	/**
46  	 * Value for {@link OperationParam#max()} indicating that the maximum will be inferred 
47  	 * from the type. If the type is a single parameter type (e.g. <code>StringDt</code>,
48  	 * <code>TokenParam</code>, <code>IBaseResource</code>) the maximum will be
49  	 * <code>1</code>. 
50  	 * <p>
51  	 * If the type is a collection, e.g.
52  	 * <code>List&lt;StringDt&gt;</code> or <code>List&lt;TokenOrListParam&gt;</code>
53  	 * the maximum will be set to <code>*</code>. If the param is a search parameter
54  	 * "and" type, such as <code>TokenAndListParam</code> the maximum will also be
55  	 * set to <code>*</code>
56  	 * </p>
57  	 * 
58  	 * @since 1.5
59  	 */
60  	final int MAX_DEFAULT = -2;
61  	
62  	/**
63  	 * The name of the parameter
64  	 */
65  	String name();
66  	
67  	/**
68  	 * The type of the parameter. This will only have effect on <code>@OperationParam</code>
69  	 * annotations specified as values for {@link Operation#returnParameters()}, otherwise the
70  	 * value will be ignored. Value should be one of:
71  	 * <ul>
72  	 * <li>A resource type, e.g. <code>Patient.class</code></li>
73  	 * <li>A datatype, e.g. <code>{@link StringDt}.class</code> or </code>CodeableConceptDt.class</code>
74  	 * <li>A RESTful search parameter type, e.g. <code>{@link StringParam}.class</code>
75  	 * </ul>
76  	 */
77  	Class<? extends IBase> type() default IBase.class;
78  	
79  	/**
80  	 * The minimum number of repetitions allowed for this child (default is 0)
81  	 */
82  	int min() default 0;
83  
84  	/**
85  	 * The maximum number of repetitions allowed for this child. Should be
86  	 * set to {@link #MAX_UNLIMITED} if there is no limit to the number of
87  	 * repetitions. See {@link #MAX_DEFAULT} for a description of the default
88  	 * behaviour.
89  	 */
90  	int max() default MAX_DEFAULT;
91  
92  	
93  }