return new AndSearchCondition< T >(conditions);
} else if (operator == BinaryOperator.OR) {
return new OrSearchCondition< T >(conditions);
}
} else {
throw new SearchParseException(
"Unsupported binary operation arguments (SearchCondition expected): "
+ leftSide + ", " + rightSide);
}
}
// Property could be either on left side (Name eq 'Tom') or
// right side ('Tom' eq Name)
TypedValue value = null;
TypedProperty property = null;
if (leftSide instanceof TypedProperty && rightSide instanceof TypedValue) {
property = (TypedProperty)leftSide;
value = (TypedValue)rightSide;
} else if (rightSide instanceof TypedProperty && leftSide instanceof TypedValue) {
property = (TypedProperty)rightSide;
value = (TypedValue)leftSide;
} else {
throw new SearchParseException(
"Unsupported binary operation arguments (TypedValue or TypedProperty expected): "
+ leftSide + ", " + rightSide);
}
ConditionType conditionType = null;
switch (operator) {
case EQ:
conditionType = ConditionType.EQUALS;
break;
case NE:
conditionType = ConditionType.NOT_EQUALS;
break;
case LT:
conditionType = ConditionType.LESS_THAN;
break;
case LE:
conditionType = ConditionType.LESS_OR_EQUALS;
break;
case GT:
conditionType = ConditionType.GREATER_THAN;
break;
case GE:
conditionType = ConditionType.GREATER_OR_EQUALS;
break;
default:
throw new SearchParseException("Unsupported binary operation: " + operator);
}
Object typedValue = null;
// If property type and value type are compatible, just use them
if (property.typeInfo.getTypeClass().isAssignableFrom(value.typeClass)) {