/** * Cast a value to the type of another field. * * @param <T> The generic type of the cast field * @param value The value to cast * @param as The field whose type is used for the cast * @return The cast field */ @Support public static <T> Field<T> cast(Object value, Field<T> as) { return Utils.field(value, as).cast(as); }
/** * Cast null to a type. * * @param <T> The generic type of the cast field * @param type The type that is used for the cast * @return The cast field */ @Support public static <T> Field<T> castNull(DataType<T> type) { return NULL().cast(type); }
/** * Cast a field to another type. * * @param <T> The generic type of the cast field * @param field The field to cast * @param type The type that is used for the cast * @return The cast field */ @Support public static <T> Field<T> cast(Field<?> field, Class<T> type) { return nullSafe(field).cast(type); }
/** * Cast null to a type. * * @param <T> The generic type of the cast field * @param type The type that is used for the cast * @return The cast field */ @Support public static <T> Field<T> castNull(Class<T> type) { return NULL().cast(type); }
/** * Cast a field to the type of another field. * * @param <T> The generic type of the cast field * @param field The field to cast * @param as The field whose type is used for the cast * @return The cast field */ @Support public static <T> Field<T> cast(Field<?> field, Field<T> as) { return nullSafe(field).cast(as); }
/** * Cast a value to another type. * * @param <T> The generic type of the cast field * @param value The value to cast * @param type The type that is used for the cast * @return The cast field */ @Support public static <T> Field<T> cast(Object value, DataType<T> type) { return Utils.field(value, type).cast(type); }
/** * Cast null to a type. * * @param <T> The generic type of the cast field * @param type The type that is used for the cast * @return The cast field */ @Support public static <T> Field<T> castNull(Class<T> type) { return NULL().cast(type); }
/** * Cast a field to another type. * * @param <T> The generic type of the cast field * @param field The value to cast * @param type The type that is used for the cast * @return The cast field */ @Support public static <T> Field<T> cast(Field<?> field, DataType<T> type) { return nullSafe(field).cast(type); }
/** * Cast a field to the type of another field. * * @param <T> The generic type of the cast field * @param field The field to cast * @param as The field whose type is used for the cast * @return The cast field */ @Support public static <T> Field<T> cast(Field<?> field, Field<T> as) { return nullSafe(field).cast(as); }
/** * Get the current_timestamp() function. * <p> * This translates into any dialect */ @Support public static Field<OffsetDateTime> currentOffsetDateTime() { return currentTimestamp().cast(SQLDataType.OFFSETDATETIME); }
/** * Cast null to a type. * * @param <T> The generic type of the cast field * @param type The type that is used for the cast * @return The cast field */ @Support public static <T> Field<T> castNull(DataType<T> type) { return NULL().cast(type); }
/** * Cast a value to the type of another field. * * @param <T> The generic type of the cast field * @param value The value to cast * @param as The field whose type is used for the cast * @return The cast field */ @Support public static <T> Field<T> cast(Object value, Field<T> as) { return Tools.field(value, as).cast(as); }
/** * Cast null to the type of another field. * * @param <T> The generic type of the cast field * @param as The field whose type is used for the cast * @return The cast field */ @Support public static <T> Field<T> castNull(Field<T> as) { return NULL().cast(as); }
/** * Cast a value to another type. * * @param <T> The generic type of the cast field * @param value The value to cast * @param type The type that is used for the cast * @return The cast field */ @Support public static <T> Field<T> cast(Object value, DataType<T> type) { return Tools.field(value).cast(type); }
/** * Cast a field to another type. * * @param <T> The generic type of the cast field * @param field The value to cast * @param type The type that is used for the cast * @return The cast field */ @Support public static <T> Field<T> cast(Field<?> field, DataType<T> type) { return nullSafe(field).cast(type); }
/** * Get the current_time() function. * <p> * This translates into any dialect */ @Support public static Field<OffsetTime> currentOffsetTime() { return currentTime().cast(SQLDataType.OFFSETTIME); }
@Override final Field<BigDecimal> getFunction0(Configuration configuration) { switch (configuration.family()) { case FIREBIRD: case SQLITE: return argument.cast(BigDecimal.class).mul(pi()).div(inline(180)); default: return function("radians", SQLDataType.NUMERIC, argument); } } }
@Override public final void accept(Context<?> ctx) { switch (ctx.family()) { default: ctx.visit(field.cast(DECIMAL)) .sql(" / ") .visit(DSL.sum(field)); toSQLOverClause(ctx); break; } } }
@Override final Field<BigDecimal> getFunction0(Configuration configuration) { switch (configuration.family()) { case FIREBIRD: case SQLITE: return argument.cast(BigDecimal.class).mul(inline(180)).div(pi()); default: return DSL.field("{degrees}({0})", SQLDataType.NUMERIC, argument); } } }
@Override final QueryPart getFunction0(Configuration configuration) { switch (configuration.dialect().family()) { case MYSQL: case MARIADB: return DSL.field("{" + name(getDataType()) + "}({0})", getDataType(), field); default: case H2: return field.cast(getDataType()); } } }