View Javadoc
1   package ca.uhn.fhir.rest.gclient;
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 static org.apache.commons.lang3.StringUtils.defaultString;
23  
24  import ca.uhn.fhir.context.FhirContext;
25  
26  public class CompositeCriterion<A extends IParam, B extends IParam> implements ICompositeWithLeft<B>, ICriterion<B>, ICriterionInternal {
27  
28  	private ICriterion<B> myRight;
29  	private String myName;
30  	private ICriterion<A> myLeft;
31  
32  	public CompositeCriterion(String theName, ICriterion<A> theLeft) {
33  		myName = theName;
34  		myLeft = theLeft;
35  	}
36  
37  	@Override
38  	public ICriterion<B> withRight(ICriterion<B> theRight) {
39  		myRight = theRight;
40  		return this;
41  	}
42  
43  	@Override
44  	public String getParameterValue(FhirContext theContext) {
45  		ICriterionInternal left = (ICriterionInternal) myLeft;
46  		ICriterionInternal right = (ICriterionInternal) myRight;
47  		return defaultString(left.getParameterValue(theContext)) + '$' + defaultString(right.getParameterValue(theContext));
48  	}
49  
50  	@Override
51  	public String getParameterName() {
52  		return myName;
53  	}
54  
55  }