if (constraint instanceof FullTextSearch) {
return constraint;
}
if (constraint instanceof Between) {
Between between = (Between)constraint;
DynamicOperand lhs = between.getOperand();
StaticOperand lower = between.getLowerBound(); // Current only a literal; therefore, no reference to selector
StaticOperand upper = between.getUpperBound(); // Current only a literal; therefore, no reference to selector
StaticOperand newLower = replaceSubqueriesWithBindVariables(context, lower, subqueriesByVariableName);
StaticOperand newUpper = replaceSubqueriesWithBindVariables(context, upper, subqueriesByVariableName);
if (lower == newLower && upper == newUpper) return between;
return new Between(lhs, newLower, newUpper, between.isLowerBoundIncluded(), between.isUpperBoundIncluded());
}
if (constraint instanceof Comparison) {
Comparison comparison = (Comparison)constraint;
DynamicOperand lhs = comparison.getOperand1();
StaticOperand rhs = comparison.getOperand2(); // Current only a literal; therefore, no reference to selector
StaticOperand newRhs = replaceSubqueriesWithBindVariables(context, rhs, subqueriesByVariableName);
if (rhs == newRhs) return comparison;
return new Comparison(lhs, comparison.operator(), newRhs);
}
if (constraint instanceof Relike) {
Relike relike = (Relike)constraint;
StaticOperand op1 = relike.getOperand1();
PropertyValue op2 = relike.getOperand2();
StaticOperand newOp1 = replaceSubqueriesWithBindVariables(context, op1, subqueriesByVariableName);
if (op1 == newOp1) return relike;
return new Relike(op1, op2);
}
if (constraint instanceof SetCriteria) {
SetCriteria criteria = (SetCriteria)constraint;
DynamicOperand lhs = criteria.leftOperand();
boolean foundSubquery = false;
List<StaticOperand> newStaticOperands = new LinkedList<StaticOperand>();
for (StaticOperand rhs : criteria.rightOperands()) {
StaticOperand newRhs = replaceSubqueriesWithBindVariables(context, rhs, subqueriesByVariableName);
newStaticOperands.add(newRhs);