View Javadoc
1   package ca.uhn.fhir.rest.annotation;
2   
3   import java.lang.annotation.ElementType;
4   
5   /*
6    * #%L
7    * HAPI FHIR - Core Library
8    * %%
9    * Copyright (C) 2014 - 2018 University Health Network
10   * %%
11   * Licensed under the Apache License, Version 2.0 (the "License");
12   * you may not use this file except in compliance with the License.
13   * You may obtain a copy of the License at
14   * 
15   * http://www.apache.org/licenses/LICENSE-2.0
16   * 
17   * Unless required by applicable law or agreed to in writing, software
18   * distributed under the License is distributed on an "AS IS" BASIS,
19   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20   * See the License for the specific language governing permissions and
21   * limitations under the License.
22   * #L%
23   */
24  
25  import java.lang.annotation.Retention;
26  import java.lang.annotation.RetentionPolicy;
27  import java.lang.annotation.Target;
28  
29  import org.hl7.fhir.instance.model.api.IBaseResource;
30  
31  import ca.uhn.fhir.model.api.IQueryParameterType;
32  import ca.uhn.fhir.rest.param.CompositeParam;
33  import ca.uhn.fhir.rest.param.ReferenceParam;
34  
35  /**
36   * Parameter annotation which specifies a search parameter for a {@link Search} method.
37   */
38  @Retention(RetentionPolicy.RUNTIME)
39  @Target(value=ElementType.PARAMETER)
40  public @interface RequiredParam {
41  
42  	/**
43  	 * For reference parameters ({@link ReferenceParam}) this value may be used to indicate which chain values (if any) are <b>not</b> valid for the given parameter. Values here will supercede any
44  	 * values specified in {@link #chainWhitelist()}
45  	 * <p>
46  	 * If the parameter annotated with this annotation is not a {@link ReferenceParam}, this value must not be populated.
47  	 * </p>
48  	 */
49  	String[] chainBlacklist() default {};
50  
51  	/**
52  	 * For reference parameters ({@link ReferenceParam}) this value may be
53  	 * used to indicate which chain values (if any) are valid for the given
54  	 * parameter. If the list contains the value {@link OptionalParam#ALLOW_CHAIN_ANY}, all values are valid. (this is the default)
55  	 * If the list contains the value {@link OptionalParam#ALLOW_CHAIN_NOTCHAINED}
56  	 * then the reference param only supports the empty chain (i.e. the resource
57  	 * ID).
58  	 * <p>
59  	 * Valid values for this parameter include:
60  	 * </p>
61  	 * <ul>
62  	 * <li><code>chainWhitelist={ OptionalParam.ALLOW_CHAIN_NOTCHAINED }</code> - Only allow resource reference (no chaining allowed for this parameter)</li>
63  	 * <li><code>chainWhitelist={ OptionalParam.ALLOW_CHAIN_ANY }</code> - Allow any chaining at all (including a non chained value, <b>this is the default</b>)</li>
64  	 * <li><code>chainWhitelist={ "foo", "bar" }</code> - Allow property.foo and property.bar</li>
65  	 * </ul>
66  	 * <p>
67  	 * Any values specified in
68  	 * {@link #chainBlacklist()} will supercede (have priority over) values
69  	 * here.
70  	 * </p>
71  	 * <p>
72  	 * If the parameter annotated with this annotation is not a {@link ReferenceParam},
73  	 * this value must not be populated.
74  	 * </p>
75  	 */
76  	String[] chainWhitelist() default { OptionalParam.ALLOW_CHAIN_ANY };
77  
78  	/**
79  	 * For composite parameters ({@link CompositeParam}) this parameter may be used to indicate the parameter type(s) which may be referenced by this param.
80  	 * <p>
81  	 * If the parameter annotated with this annotation is not a {@link CompositeParam}, this value must not be populated.
82  	 * </p>
83  	 */
84  	Class<? extends IQueryParameterType>[] compositeTypes() default {};
85  
86  	/**
87  	 * This is the name for the parameter. Generally this should be a simple string (e.g. "name", or "identifier") which will be the name of the URL parameter used to populate this method parameter.
88  	 * <p>
89  	 * Most resource model classes have constants which may be used to supply values for this field, e.g. Patient.SP_NAME or Observation.SP_DATE
90  	 * </p>
91  	 * <p>
92  	 * If you wish to specify a parameter for a resource reference which only accepts a specific chained value, it is also valid to supply a chained name here, such as "patient.name". It is
93  	 * recommended to supply this using constants where possible, e.g. <code>Observation.SP_SUBJECT + '.' + Patient.SP_IDENTIFIER</code>
94  	 * </p>
95  	 */
96  	String name();
97  
98  	/**
99  	 * For resource reference parameters ({@link ReferenceParam}) this parameter may be used to indicate the resource type(s) which may be referenced by this param.
100 	 * <p>
101 	 * If the parameter annotated with this annotation is not a {@link ReferenceParam}, this value must not be populated.
102 	 * </p>
103 	 */
104 	Class<? extends IBaseResource>[] targetTypes() default {};
105 
106 }