io.ebeaninternal.server.expression.platform.PostgresCast Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ebean Show documentation
Show all versions of ebean Show documentation
composite of common runtime dependencies for all platforms
package io.ebeaninternal.server.expression.platform;
/**
* Helper for determining type casting for JSON and ARRAY expressions.
*/
public class PostgresCast {
/**
* Postgres CAST the type if necessary.
*
* This is generally necessary for JSON expressions as text values always returned from the json operators used.
*
*/
protected static String cast(Object value) {
return cast(value, false);
}
/**
* Postgres CAST the type if necessary additionally specify if DB ARRAY is used.
*/
protected static String cast(Object value, boolean asArray) {
if (value == null) {
// for exists and not-exists expressions
return "";
}
if (value instanceof Integer) {
return asArray ? "::integer[]" : "::integer";
}
if (value instanceof Long) {
return asArray ? "::bigint[]" : "::bigint";
}
if (value instanceof Number) {
return asArray ? "::decimal[]" : "::decimal";
}
if (value instanceof Boolean) {
return asArray ? "::boolean[]" : "::boolean";
}
return "";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy