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 OptionalParam {
41  
42  	public static final String ALLOW_CHAIN_ANY = "*";
43  
44  	public static final String ALLOW_CHAIN_NOTCHAINED = "";
45  
46  	/**
47  	 * For reference parameters ({@link ReferenceParam}) this value may be
48  	 * used to indicate which chain values (if any) are <b>not</b> valid
49  	 * for the given parameter. Values here will supercede any values specified
50  	 * in {@link #chainWhitelist()}
51  	 * <p>
52  	 * If the parameter annotated with this annotation is not a {@link ReferenceParam},
53  	 * this value must not be populated.
54  	 * </p>
55  	 */
56  	String[] chainBlacklist() default {};
57  
58  	/**
59  	 * For reference parameters ({@link ReferenceParam}) this value may be
60  	 * used to indicate which chain values (if any) are valid for the given
61  	 * parameter. If the list contains the value {@link #ALLOW_CHAIN_ANY}, all values are valid. (this is the default)
62  	 * If the list contains the value {@link #ALLOW_CHAIN_NOTCHAINED}
63  	 * then the reference param only supports the empty chain (i.e. the resource
64  	 * ID).
65  	 * <p>
66  	 * Valid values for this parameter include:
67  	 * </p>
68  	 * <ul>
69  	 * <li><code>chainWhitelist={ OptionalParam.ALLOW_CHAIN_NOTCHAINED }</code> - Only allow resource reference (no chaining allowed for this parameter)</li>
70  	 * <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>
71  	 * <li><code>chainWhitelist={ "foo", "bar" }</code> - Allow property.foo and property.bar</li>
72  	 * </ul>
73  	 * <p>
74  	 * Any values specified in
75  	 * {@link #chainBlacklist()} will supercede (have priority over) values
76  	 * here.
77  	 * </p>
78  	 * <p>
79  	 * If the parameter annotated with this annotation is not a {@link ReferenceParam},
80  	 * this value must not be populated.
81  	 * </p>
82  	 */
83  	String[] chainWhitelist() default { ALLOW_CHAIN_ANY };
84  
85  	/**
86  	 * For composite parameters ({@link CompositeParam}) this value may be
87  	 * used to indicate the parameter type(s) which may be referenced by this param.
88  	 * <p>
89  	 * If the parameter annotated with this annotation is not a {@link CompositeParam},
90  	 * this value must not be populated.
91  	 * </p>
92  	 */
93  	Class<? extends IQueryParameterType>[] compositeTypes() default {};
94  
95  	/**
96  	 * This is the name for the parameter. Generally this should be a
97  	 * simple string (e.g. "name", or "identifier") which will be the name
98  	 * of the URL parameter used to populate this method parameter.
99  	 * <p>
100 	 * Most resource model classes have constants which may be used to
101 	 * supply values for this field, e.g. <code>Patient.SP_NAME</code> or
102 	 * <code>Observation.SP_DATE</code>
103 	 * </p>
104 	 * <p>
105 	 * If you wish to specify a parameter for a resource reference which
106 	 * only accepts a specific chained value, it is also valid to supply
107 	 * a chained name here, such as "patient.name". It is recommended to
108 	 * supply this using constants where possible, e.g.
109 	 * <code>Observation.SP_SUBJECT + '.' + Patient.SP_IDENTIFIER</code>
110 	 * </p>
111 	 */
112 	String name();
113 
114 	/**
115 	 * For resource reference parameters ({@link ReferenceParam}) this value may be
116 	 * used to indicate the resource type(s) which may be referenced by this param.
117 	 * <p>
118 	 * If the parameter annotated with this annotation is not a {@link ReferenceParam},
119 	 * this value must not be populated.
120 	 * </p>
121 	 */
122 	Class<? extends IBaseResource>[] targetTypes() default {};
123 }