}
if (type.equals(DOUBLE)) {
Double value = (Double) object;
if (value.isNaN()) {
return new FunctionCall(new QualifiedName("nan"), ImmutableList.<Expression>of());
}
else if (value == Double.NEGATIVE_INFINITY) {
return new NegativeExpression(new FunctionCall(new QualifiedName("infinity"), ImmutableList.<Expression>of()));
}
else if (value == Double.POSITIVE_INFINITY) {
return new FunctionCall(new QualifiedName("infinity"), ImmutableList.<Expression>of());
}
else {
return new DoubleLiteral(object.toString());
}
}
if (type.equals(VARCHAR)) {
if (object instanceof Slice) {
return new StringLiteral(((Slice) object).toString(UTF_8));
}
if (object instanceof String) {
return new StringLiteral((String) object);
}
}
if (type.equals(BOOLEAN)) {
return new BooleanLiteral(object.toString());
}
Signature signature = FunctionRegistry.getMagicLiteralFunctionSignature(type);
Expression rawLiteral = toExpression(object, FunctionRegistry.type(type.getJavaType()));
return new FunctionCall(new QualifiedName(signature.getName()), ImmutableList.of(rawLiteral));
}