View Javadoc
1   package ca.uhn.fhir.rest.gclient;
2   
3   import ca.uhn.fhir.model.primitive.IdDt;
4   
5   /*
6    * #%L
7    * HAPI FHIR - Core Library
8    * %%
9    * Copyright (C) 2014 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  
26  public class ReferenceClientParam implements IParam {
27  
28  	private String myName;
29  
30  	public ReferenceClientParam(String theName) {
31  		myName = theName;
32  	}
33  
34  	@Override
35  	public String getParamName() {
36  		return myName;
37  	}
38  	
39  	public ICriterion<ReferenceClientParam> hasChainedProperty(ICriterion<?> theCriterion) {
40  		return new ReferenceChainCriterion(getParamName(), theCriterion);
41  	}
42  
43  	/**
44  	 * Match the referenced resource if the resource has the given ID (this can be
45  	 * the logical ID or the absolute URL of the resource)
46  	 */
47  	public ICriterion<ReferenceClientParam> hasId(IdDt theId) {
48  		return new StringCriterion<ReferenceClientParam>(getParamName(), theId.getValue());
49  	}
50  
51  	/**
52  	 * Match the referenced resource if the resource has the given ID (this can be
53  	 * the logical ID or the absolute URL of the resource)
54  	 */
55  	public ICriterion<ReferenceClientParam> hasId(String theId) {
56  		return new StringCriterion<ReferenceClientParam>(getParamName(), theId);
57  	}
58  
59  	private static class ReferenceChainCriterion implements ICriterion<ReferenceClientParam>, ICriterionInternal {
60  
61  		private String myParamName;
62  		private ICriterionInternal myWrappedCriterion;
63  
64  		public ReferenceChainCriterion(String theParamName, ICriterion<?> theWrappedCriterion) {
65  			myParamName = theParamName;
66  			myWrappedCriterion = (ICriterionInternal) theWrappedCriterion;
67  		}
68  
69  		@Override
70  		public String getParameterName() {
71  			return myParamName + "." + myWrappedCriterion.getParameterName();
72  		}
73  
74  		@Override
75  		public String getParameterValue() {
76  			return myWrappedCriterion.getParameterValue();
77  		}
78  
79  	}
80  
81  }