diff --git a/jOOQ/src/main/java/org/jooq/Field.java b/jOOQ/src/main/java/org/jooq/Field.java index 7b5ef95ac8..43a095a197 100644 --- a/jOOQ/src/main/java/org/jooq/Field.java +++ b/jOOQ/src/main/java/org/jooq/Field.java @@ -151,97 +151,6 @@ extends // API // ------------------------------------------------------------------------ - /** - * Apply an ad-hoc data type {@link Binding} to this field expression. - *

- * Rather than attaching data type bindings at code generation time, or - * creating cumbersome expressions using - * {@link DataType#asConvertedDataType(Binding)}, this method allows for - * creating a derived field expression with an ad-hoc data type binding for - * single query usage. - * - * @param The user type. - * @param binding The binding to be applied on any operations using this - * field. - * @return A derived field expression using a new binding. - */ - @NotNull - Field convert(Binding binding); - - /** - * Apply an ad-hoc data type {@link Converter} to this field expression. - *

- * Rather than attaching data type converters at code generation time, or - * creating cumbersome expressions using - * {@link DataType#asConvertedDataType(Converter)}, this method allows for - * creating a derived field expression with an ad-hoc data type converter for - * single query usage. - * - * @param The user type. - * @param converter The converter to be applied on any operations using this - * field. - * @return A derived field expression using a new converter. - */ - @NotNull - Field convert(Converter converter); - - /** - * Apply an ad-hoc data type {@link Converter} to this field expression. - *

- * Rather than attaching data type converters at code generation time, or - * creating cumbersome expressions using - * {@link DataType#asConvertedDataType(Class, Function, Function)}, this - * method allows for creating a derived field expression with an ad-hoc data - * type converter for single query usage. - * - * @param The user type. - * @param converter The converter to be applied on any operations using this - * field. - * @return A derived field expression using a new converter. - */ - @NotNull - Field convert( - Class toType, - Function from, - Function to - ); - - /** - * Apply an ad-hoc read-only data type {@link Converter} to this field - * expression. - *

- * Rather than attaching data type converters at code generation time, or - * creating cumbersome expressions using - * {@link DataType#asConvertedDataTypeFrom(Class, Function)}, this method - * allows for creating a derived field expression with an ad-hoc data type - * converter for single query usage. - * - * @param The user type. - * @param converter The read-only converter to be applied on any operations - * using this field. - * @return A derived field expression using a new converter. - */ - @NotNull - Field convertFrom(Class toType, Function from); - - /** - * Apply an ad-hoc write-only data type {@link Converter} to this field - * expression. - *

- * Rather than attaching data type converters at code generation time, or - * creating cumbersome expressions using - * {@link DataType#asConvertedDataTypeTo(Class, Function)}, this method - * allows for creating a derived field expression with an ad-hoc data type - * converter for single query usage. - * - * @param The user type. - * @param converter The write-only converter to be applied on any operations - * using this field. - * @return A derived field expression using a new converter. - */ - @NotNull - Field convertTo(Class toType, Function to); - /** * The name of the field. *

diff --git a/jOOQ/src/main/java/org/jooq/SelectField.java b/jOOQ/src/main/java/org/jooq/SelectField.java index 2555fc736a..2f1f4d47b7 100644 --- a/jOOQ/src/main/java/org/jooq/SelectField.java +++ b/jOOQ/src/main/java/org/jooq/SelectField.java @@ -37,6 +37,8 @@ */ package org.jooq; +import java.util.function.Function; + import org.jooq.conf.Settings; import org.jooq.impl.DSL; @@ -94,4 +96,95 @@ public interface SelectField extends SelectFieldOrAsterisk, Named, Typed { @Support Field as(Field otherField); + /** + * Apply an ad-hoc data type {@link Binding} to this field expression. + *

+ * Rather than attaching data type bindings at code generation time, or + * creating cumbersome expressions using + * {@link DataType#asConvertedDataType(Binding)}, this method allows for + * creating a derived field expression with an ad-hoc data type binding for + * single query usage. + * + * @param The user type. + * @param binding The binding to be applied on any operations using this + * field. + * @return A derived field expression using a new binding. + */ + @NotNull + Field convert(Binding binding); + + /** + * Apply an ad-hoc data type {@link Converter} to this field expression. + *

+ * Rather than attaching data type converters at code generation time, or + * creating cumbersome expressions using + * {@link DataType#asConvertedDataType(Converter)}, this method allows for + * creating a derived field expression with an ad-hoc data type converter for + * single query usage. + * + * @param The user type. + * @param converter The converter to be applied on any operations using this + * field. + * @return A derived field expression using a new converter. + */ + @NotNull + Field convert(Converter converter); + + /** + * Apply an ad-hoc data type {@link Converter} to this field expression. + *

+ * Rather than attaching data type converters at code generation time, or + * creating cumbersome expressions using + * {@link DataType#asConvertedDataType(Class, Function, Function)}, this + * method allows for creating a derived field expression with an ad-hoc data + * type converter for single query usage. + * + * @param The user type. + * @param converter The converter to be applied on any operations using this + * field. + * @return A derived field expression using a new converter. + */ + @NotNull + Field convert( + Class toType, + Function from, + Function to + ); + + /** + * Apply an ad-hoc read-only data type {@link Converter} to this field + * expression. + *

+ * Rather than attaching data type converters at code generation time, or + * creating cumbersome expressions using + * {@link DataType#asConvertedDataTypeFrom(Class, Function)}, this method + * allows for creating a derived field expression with an ad-hoc data type + * converter for single query usage. + * + * @param The user type. + * @param converter The read-only converter to be applied on any operations + * using this field. + * @return A derived field expression using a new converter. + */ + @NotNull + Field convertFrom(Class toType, Function from); + + /** + * Apply an ad-hoc write-only data type {@link Converter} to this field + * expression. + *

+ * Rather than attaching data type converters at code generation time, or + * creating cumbersome expressions using + * {@link DataType#asConvertedDataTypeTo(Class, Function)}, this method + * allows for creating a derived field expression with an ad-hoc data type + * converter for single query usage. + * + * @param The user type. + * @param converter The write-only converter to be applied on any operations + * using this field. + * @return A derived field expression using a new converter. + */ + @NotNull + Field convertTo(Class toType, Function to); + } diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractRow.java b/jOOQ/src/main/java/org/jooq/impl/AbstractRow.java index 6ad1f6f726..875a88378e 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractRow.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractRow.java @@ -43,6 +43,7 @@ import static org.jooq.impl.Keywords.K_ROW; import static org.jooq.impl.QueryPartListView.wrap; import java.util.Collection; +import java.util.function.Function; import java.util.stream.Stream; import org.jooq.Binding; @@ -107,6 +108,31 @@ abstract class AbstractRow extends AbstractQueryPart implement return rf().as(alias); } + @Override + public final Field convert(Binding binding) { + return rf().convert(binding); + } + + @Override + public final Field convert(Converter converter) { + return rf().convert(converter); + } + + @Override + public final Field convert(Class toType, Function from, Function to) { + return rf().convert(toType, from, to); + } + + @Override + public final Field convertFrom(Class toType, Function from) { + return rf().convertFrom(toType, from); + } + + @Override + public final Field convertTo(Class toType, Function to) { + return rf().convertTo(toType, to); + } + @Override public final Field as(Field otherField) { return rf().as(otherField);