default:
throw new ODataNotImplementedException();
}
case BINARY:
final BinaryExpression binaryExpression = (BinaryExpression) expression;
final EdmSimpleType type = (EdmSimpleType) binaryExpression.getLeftOperand().getEdmType();
final String left = evaluateExpression(data, binaryExpression.getLeftOperand());
final String right = evaluateExpression(data, binaryExpression.getRightOperand());
switch (binaryExpression.getOperator()) {
case ADD:
if (binaryExpression.getEdmType() == EdmSimpleTypeKind.Decimal.getEdmSimpleTypeInstance()
|| binaryExpression.getEdmType() == EdmSimpleTypeKind.Double.getEdmSimpleTypeInstance()
|| binaryExpression.getEdmType() == EdmSimpleTypeKind.Single.getEdmSimpleTypeInstance()) {
return Double.toString(Double.valueOf(left) + Double.valueOf(right));
} else {
return Long.toString(Long.valueOf(left) + Long.valueOf(right));
}
case SUB:
if (binaryExpression.getEdmType() == EdmSimpleTypeKind.Decimal.getEdmSimpleTypeInstance()
|| binaryExpression.getEdmType() == EdmSimpleTypeKind.Double.getEdmSimpleTypeInstance()
|| binaryExpression.getEdmType() == EdmSimpleTypeKind.Single.getEdmSimpleTypeInstance()) {
return Double.toString(Double.valueOf(left) - Double.valueOf(right));
} else {
return Long.toString(Long.valueOf(left) - Long.valueOf(right));
}
case MUL:
if (binaryExpression.getEdmType() == EdmSimpleTypeKind.Decimal.getEdmSimpleTypeInstance()
|| binaryExpression.getEdmType() == EdmSimpleTypeKind.Double.getEdmSimpleTypeInstance()
|| binaryExpression.getEdmType() == EdmSimpleTypeKind.Single.getEdmSimpleTypeInstance()) {
return Double.toString(Double.valueOf(left) * Double.valueOf(right));
} else {
return Long.toString(Long.valueOf(left) * Long.valueOf(right));
}
case DIV:
final String number = Double.toString(Double.valueOf(left) / Double.valueOf(right));
return number.endsWith(".0") ? number.replace(".0", "") : number;
case MODULO:
if (binaryExpression.getEdmType() == EdmSimpleTypeKind.Decimal.getEdmSimpleTypeInstance()
|| binaryExpression.getEdmType() == EdmSimpleTypeKind.Double.getEdmSimpleTypeInstance()
|| binaryExpression.getEdmType() == EdmSimpleTypeKind.Single.getEdmSimpleTypeInstance()) {
return Double.toString(Double.valueOf(left) % Double.valueOf(right));
} else {
return Long.toString(Long.valueOf(left) % Long.valueOf(right));
}
case AND: