[jOOQ/jOOQ#13961] Rename ConverterScope to ConverterContext

See also [jOOQ/jOOQ#13801]
This commit is contained in:
Lukas Eder 2022-09-06 12:41:25 +02:00
parent 4a7410f4b1
commit 207ed16668
42 changed files with 208 additions and 208 deletions

View File

@ -56,7 +56,7 @@ final class ArrayComponentConverter<T, U> extends AbstractScopedConverter<T, U>
}
@Override
public final U from(T t, ConverterScope scope) {
public final U from(T t, ConverterContext scope) {
if (t == null)
return null;
@ -66,7 +66,7 @@ final class ArrayComponentConverter<T, U> extends AbstractScopedConverter<T, U>
}
@Override
public final T to(U u, ConverterScope scope) {
public final T to(U u, ConverterContext scope) {
if (u == null)
return null;

View File

@ -61,12 +61,12 @@ final class ArrayConverter<T, U> extends AbstractScopedConverter<T[], U[]> {
}
@Override
public final U[] from(T[] t, ConverterScope scope) {
public final U[] from(T[] t, ConverterContext scope) {
return Convert.convertArray(t, converter);
}
@Override
public final T[] to(U[] t, ConverterScope scope) {
public final T[] to(U[] t, ConverterContext scope) {
return Convert.convertArray(t, inverse);
}
}

View File

@ -99,8 +99,8 @@ import java.sql.SQLOutput;
public interface BindingScope extends Scope {
/**
* Get the {@link ConverterScope} from the context of this
* Get the {@link ConverterContext} from the context of this
* {@link BindingScope}.
*/
ConverterScope converterScope();
ConverterContext converterContext();
}

View File

@ -175,12 +175,12 @@ public interface Converter<T, U> extends Serializable {
return new AbstractScopedConverter<T, U>(fromType, toType) {
@Override
public final U from(T t, ConverterScope scope) {
public final U from(T t, ConverterContext scope) {
return from.apply(t);
}
@Override
public final T to(U u, ConverterScope scope) {
public final T to(U u, ConverterContext scope) {
return to.apply(u);
}
};

View File

@ -43,6 +43,6 @@ package org.jooq;
* <p>
* Implementations
*/
public interface ConverterScope extends Scope {
public interface ConverterContext extends Scope {
}

View File

@ -195,7 +195,7 @@ public final class Converters<T, U> extends AbstractScopedConverter<T, U> {
}
@Override
public final U from(T t, ConverterScope scope) {
public final U from(T t, ConverterContext scope) {
Object result = t;
for (int i = 0; i < chain.length; i++)
@ -205,7 +205,7 @@ public final class Converters<T, U> extends AbstractScopedConverter<T, U> {
}
@Override
public final T to(U u, ConverterScope scope) {
public final T to(U u, ConverterContext scope) {
Object result = u;
for (int i = chain.length - 1; i >= 0; i--)
@ -237,9 +237,9 @@ public final class Converters<T, U> extends AbstractScopedConverter<T, U> {
: f.apply(t) : t -> t == null ? null : f.apply(t);
}
static final <T, U> BiFunction<T, ConverterScope, U> nullable(BiFunction<? super T, ? super ConverterScope, ? extends U> f) {
static final <T, U> BiFunction<T, ConverterContext, U> nullable(BiFunction<? super T, ? super ConverterContext, ? extends U> f) {
return f instanceof Serializable
? (BiFunction<T, ConverterScope, U> & Serializable) (t, x) -> t == null ? null
? (BiFunction<T, ConverterContext, U> & Serializable) (t, x) -> t == null ? null
: f.apply(t, x) : (t, x) -> t == null ? null : f.apply(t, x);
}
@ -247,7 +247,7 @@ public final class Converters<T, U> extends AbstractScopedConverter<T, U> {
return t -> { throw new DataTypeException("Conversion function not implemented"); };
}
static final <T, U> BiFunction<T, ConverterScope, U> notImplementedBiFunction() {
static final <T, U> BiFunction<T, ConverterContext, U> notImplementedBiFunction() {
return (t, x) -> { throw new DataTypeException("Conversion function not implemented"); };
}

View File

@ -72,10 +72,10 @@ import org.jetbrains.annotations.Nullable;
public interface ExecuteContext extends Scope {
/**
* Get a {@link ConverterScope} for the scope of this
* Get a {@link ConverterContext} for the scope of this
* {@link ExecuteContext}.
*/
ConverterScope converterScope();
ConverterContext converterContext();
/**
* The connection to be used in this execute context.

View File

@ -45,10 +45,10 @@ import org.jetbrains.annotations.Nullable;
public interface ExecuteScope extends Scope {
/**
* Get the {@link ConverterScope} from the context of this
* Get the {@link ConverterContext} from the context of this
* {@link ExecuteScope}.
*/
ConverterScope converterScope();
ConverterContext converterContext();
/**
* The {@link ExecuteContext} that created this scope.

View File

@ -39,7 +39,7 @@ package org.jooq;
import static org.jooq.Converters.notImplementedBiFunction;
import static org.jooq.Converters.nullable;
import static org.jooq.impl.Internal.converterScope;
import static org.jooq.impl.Internal.converterContext;
import java.util.function.BiFunction;
import java.util.function.Function;
@ -50,12 +50,12 @@ import org.jetbrains.annotations.NotNull;
/**
* A special type of {@link Converter} with alternative
* {@link #from(Object, ConverterScope)} and {@link #to(Object, ConverterScope)}
* {@link #from(Object, ConverterContext)} and {@link #to(Object, ConverterContext)}
* methods.
* <p>
* This special converter type can be used wherever an ordinary
* {@link Converter} is used. jOOQ internal call sites will call the alternative
* {@link #from(Object, ConverterScope)} and {@link #to(Object, ConverterScope)}
* {@link #from(Object, ConverterContext)} and {@link #to(Object, ConverterContext)}
* methods, instead of {@link #from(Object)} and {@link #to(Object)}, allowing
* for accessing global {@link Configuration#data()} content.
*/
@ -68,7 +68,7 @@ public interface ScopedConverter<T, U> extends Converter<T, U> {
* @param scope The scope of this conversion.
* @return The user object.
*/
U from(T databaseObject, ConverterScope scope);
U from(T databaseObject, ConverterContext scope);
/**
* Convert and write a user object to a database object.
@ -77,16 +77,16 @@ public interface ScopedConverter<T, U> extends Converter<T, U> {
* @param scope The scope of this conversion.
* @return The database object.
*/
T to(U userObject, ConverterScope scope);
T to(U userObject, ConverterContext scope);
@Override
default T to(U userObject) {
return to(userObject, converterScope());
return to(userObject, converterContext());
}
@Override
default U from(T databaseObject) {
return from(databaseObject, converterScope());
return from(databaseObject, converterContext());
}
/**
@ -126,12 +126,12 @@ public interface ScopedConverter<T, U> extends Converter<T, U> {
else
return new AbstractScopedConverter<T, U>(converter.fromType(), converter.toType()) {
@Override
public U from(T t, ConverterScope scope) {
public U from(T t, ConverterContext scope) {
return converter.from(t);
}
@Override
public T to(U u, ConverterScope scope) {
public T to(U u, ConverterContext scope) {
return converter.to(u);
}
};
@ -154,7 +154,7 @@ public interface ScopedConverter<T, U> extends Converter<T, U> {
static <T, U> ScopedConverter<T, U> from(
Class<T> fromType,
Class<U> toType,
BiFunction<? super T, ? super ConverterScope, ? extends U> from
BiFunction<? super T, ? super ConverterContext, ? extends U> from
) {
return of(fromType, toType, from, notImplementedBiFunction());
}
@ -176,7 +176,7 @@ public interface ScopedConverter<T, U> extends Converter<T, U> {
static <T, U> ScopedConverter<T, U> to(
Class<T> fromType,
Class<U> toType,
BiFunction<? super U, ? super ConverterScope, ? extends T> to
BiFunction<? super U, ? super ConverterContext, ? extends T> to
) {
return of(fromType, toType, notImplementedBiFunction(), to);
}
@ -198,18 +198,18 @@ public interface ScopedConverter<T, U> extends Converter<T, U> {
static <T, U> ScopedConverter<T, U> of(
Class<T> fromType,
Class<U> toType,
BiFunction<? super T, ? super ConverterScope, ? extends U> from,
BiFunction<? super U, ? super ConverterScope, ? extends T> to
BiFunction<? super T, ? super ConverterContext, ? extends U> from,
BiFunction<? super U, ? super ConverterContext, ? extends T> to
) {
return new AbstractScopedConverter<T, U>(fromType, toType) {
@Override
public final U from(T t, ConverterScope scope) {
public final U from(T t, ConverterContext scope) {
return from.apply(t, scope);
}
@Override
public final T to(U u, ConverterScope scope) {
public final T to(U u, ConverterContext scope) {
return to.apply(u, scope);
}
};
@ -248,8 +248,8 @@ public interface ScopedConverter<T, U> extends Converter<T, U> {
static <T, U> ScopedConverter<T, U> ofNullable(
Class<T> fromType,
Class<U> toType,
BiFunction<? super T, ? super ConverterScope, ? extends U> from,
BiFunction<? super U, ? super ConverterScope, ? extends T> to
BiFunction<? super T, ? super ConverterContext, ? extends U> from,
BiFunction<? super U, ? super ConverterContext, ? extends T> to
) {
return of(fromType, toType, nullable(from), nullable(to));
}
@ -284,7 +284,7 @@ public interface ScopedConverter<T, U> extends Converter<T, U> {
static <T, U> Converter<T, U> fromNullable(
Class<T> fromType,
Class<U> toType,
BiFunction<? super T, ? super ConverterScope, ? extends U> from
BiFunction<? super T, ? super ConverterContext, ? extends U> from
) {
return of(fromType, toType, nullable(from), notImplementedBiFunction());
}
@ -318,7 +318,7 @@ public interface ScopedConverter<T, U> extends Converter<T, U> {
static <T, U> Converter<T, U> toNullable(
Class<T> fromType,
Class<U> toType,
BiFunction<? super U, ? super ConverterScope, ? extends T> to
BiFunction<? super U, ? super ConverterContext, ? extends T> to
) {
return of(fromType, toType, notImplementedBiFunction(), nullable(to));
}

View File

@ -78,7 +78,7 @@ import org.jooq.Clause;
import org.jooq.Condition;
import org.jooq.Configuration;
import org.jooq.Context;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
import org.jooq.DSLContext;
import org.jooq.ExecuteContext;
import org.jooq.Field;
@ -237,8 +237,8 @@ abstract class AbstractContext<C extends Context<C>> extends AbstractScope imple
// ------------------------------------------------------------------------
@Override
public final ConverterScope converterScope() {
return ctx != null ? ctx.converterScope() : Tools.converterScope(configuration());
public final ConverterContext converterContext() {
return ctx != null ? ctx.converterContext() : Tools.converterContext(configuration());
}
@Override

View File

@ -37,7 +37,7 @@
*/
package org.jooq.impl;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
import org.jooq.ExecuteContext;
import org.jooq.ExecuteScope;
@ -57,8 +57,8 @@ abstract class AbstractExecuteScope extends AbstractScope implements ExecuteScop
}
@Override
public final ConverterScope converterScope() {
return ctx.converterScope();
public final ConverterContext converterContext() {
return ctx.converterContext();
}
@Override

View File

@ -44,7 +44,7 @@ import static org.jooq.ScopedConverter.scoped;
import static org.jooq.conf.SettingsTools.updatablePrimaryKeys;
import static org.jooq.impl.Tools.EMPTY_FIELD;
import static org.jooq.impl.Tools.converterOrFail;
import static org.jooq.impl.Tools.converterScope;
import static org.jooq.impl.Tools.converterContext;
import static org.jooq.impl.Tools.embeddedFields;
import static org.jooq.impl.Tools.indexFail;
import static org.jooq.impl.Tools.indexOrFail;
@ -336,12 +336,12 @@ abstract class AbstractRecord extends AbstractStore implements Record {
@Override
public final <U> U get(Field<?> field, Class<? extends U> type) {
Object t = get(field);
return (U) converterOrFail(this, t, (Class) field.getType(), type).from(t, converterScope(this));
return (U) converterOrFail(this, t, (Class) field.getType(), type).from(t, converterContext(this));
}
@Override
public final <T, U> U get(Field<T> field, Converter<? super T, ? extends U> converter) {
return scoped(converter).from(get(field), converterScope(this));
return scoped(converter).from(get(field), converterContext(this));
}
@Override
@ -352,7 +352,7 @@ abstract class AbstractRecord extends AbstractStore implements Record {
@Override
public final <U> U get(int index, Class<? extends U> type) {
Object t = get(index);
return (U) converterOrFail(this, t, (Class) field(safeIndex(index)).getType(), type).from(t, converterScope(this));
return (U) converterOrFail(this, t, (Class) field(safeIndex(index)).getType(), type).from(t, converterContext(this));
}
@Override
@ -475,7 +475,7 @@ abstract class AbstractRecord extends AbstractStore implements Record {
@Override
public final <T, U> void set(Field<T> field, U value, Converter<? extends T, ? super U> converter) {
set(field, scoped(converter).to(value, converterScope(this)));
set(field, scoped(converter).to(value, converterContext(this)));
}
@Override

View File

@ -56,7 +56,7 @@ import jakarta.xml.bind.annotation.XmlRootElement;
import javax.xml.namespace.QName;
import org.jooq.Converter;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
import org.jooq.XML;
/**
@ -103,7 +103,7 @@ public class AbstractXMLasObjectBinding<T> extends AbstractXMLBinding<T> {
}
@Override
public T from(XML t, ConverterScope scope) {
public T from(XML t, ConverterContext scope) {
if (t == null)
return null;
@ -111,7 +111,7 @@ public class AbstractXMLasObjectBinding<T> extends AbstractXMLBinding<T> {
}
@Override
public XML to(T u, ConverterScope scope) {
public XML to(T u, ConverterContext scope) {
if (u == null)
return null;

View File

@ -42,7 +42,7 @@ import static java.time.temporal.ChronoField.MILLI_OF_DAY;
import static java.time.temporal.ChronoField.MILLI_OF_SECOND;
import static org.jooq.ScopedConverter.scoped;
import static org.jooq.impl.Internal.arrayType;
import static org.jooq.impl.Internal.converterScope;
import static org.jooq.impl.Internal.converterContext;
import static org.jooq.impl.Tools.configuration;
import static org.jooq.impl.Tools.emulateMultiset;
import static org.jooq.tools.reflect.Reflect.accessible;
@ -95,7 +95,7 @@ import java.util.regex.Pattern;
// ...
import org.jooq.Converter;
import org.jooq.ConverterProvider;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
import org.jooq.EnumType;
import org.jooq.Field;
import org.jooq.JSON;
@ -403,7 +403,7 @@ final class Convert {
}
static final <U> U[] convertCollection(Collection from, Class<? extends U[]> to){
return new ConvertAll<U[]>(to).from(from, converterScope());
return new ConvertAll<U[]>(to).from(from, converterContext());
}
/**
@ -433,10 +433,10 @@ final class Convert {
Class<T> fromType = converter.fromType();
if (fromType == Object.class)
return scoped(converter).from((T) from, converterScope());
return scoped(converter).from((T) from, converterContext());
ConvertAll<T> convertAll = new ConvertAll<>(fromType);
return scoped(converter).from(convertAll.from(from, converterScope()), converterScope());
return scoped(converter).from(convertAll.from(from, converterContext()), converterContext());
}
/**
@ -547,7 +547,7 @@ final class Convert {
List<U> result = new ArrayList<>(collection.size());
for (Object o : collection)
result.add(convert(all.from(o, converterScope()), converter));
result.add(convert(all.from(o, converterContext()), converter));
return result;
}
@ -573,7 +573,7 @@ final class Convert {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public U from(Object from, ConverterScope scope) {
public U from(Object from, ConverterContext scope) {
if (from == null) {
// [#936] If types are converted to primitives, the result must not
@ -1402,7 +1402,7 @@ final class Convert {
}
@Override
public Object to(U to, ConverterScope scope) {
public Object to(U to, ConverterContext scope) {
return to;
}

View File

@ -37,7 +37,7 @@
*/
package org.jooq.impl;
import static org.jooq.impl.Internal.converterScope;
import static org.jooq.impl.Internal.converterContext;
import java.util.List;
import java.util.Map;
@ -309,7 +309,7 @@ final class ConvertedDataType<T, U> extends AbstractDataTypeX<U> {
// [#3200] Try to convert arbitrary objects to T
else
return ((ScopedConverter<T, U>) getConverter()).from(delegate.convert(object), converterScope());
return ((ScopedConverter<T, U>) getConverter()).from(delegate.convert(object), converterContext());
}
@Override

View File

@ -1571,7 +1571,7 @@ final class CursorImpl<R extends Record> extends AbstractCursor<R> {
// [#7100] TODO: Is there a more elegant way to do this?
if (f != field)
value = ((ScopedConverter<Object, T>) field.getConverter()).from(value, ctx.converterScope());
value = ((ScopedConverter<Object, T>) field.getConverter()).from(value, ctx.converterContext());
offset += operation.offset - nestedOffset + nested.size() - 1;
}

View File

@ -42,7 +42,7 @@ import java.time.LocalDate;
import java.util.function.Function;
import org.jooq.Converter;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
/**
* @author Lukas Eder
@ -59,12 +59,12 @@ public final class DateToLocalDateConverter extends AbstractScopedConverter<Date
}
@Override
public final LocalDate from(Date t, ConverterScope scope) {
public final LocalDate from(Date t, ConverterContext scope) {
return t == null ? null : t.toLocalDate();
}
@Override
public final Date to(LocalDate u, ConverterScope scope) {
public final Date to(LocalDate u, ConverterContext scope) {
return u == null ? null : Date.valueOf(u);
}
}

View File

@ -231,7 +231,7 @@ import org.jooq.BindingSetStatementContext;
import org.jooq.Configuration;
import org.jooq.Context;
import org.jooq.Converter;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
import org.jooq.Converters;
import org.jooq.DataType;
import org.jooq.EnumType;
@ -376,8 +376,8 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
return (Binding<T, U>) new DelegatingBinding<>(
(DataType<LocalDate>) dataType,
ScopedConverter.ofNullable(Date.class, LocalDate.class,
(BiFunction<Date, ConverterScope, LocalDate> & Serializable) (t, x) -> t.toLocalDate(),
(BiFunction<LocalDate, ConverterScope, Date> & Serializable) (t, x) -> Date.valueOf(t)
(BiFunction<Date, ConverterContext, LocalDate> & Serializable) (t, x) -> t.toLocalDate(),
(BiFunction<LocalDate, ConverterContext, Date> & Serializable) (t, x) -> Date.valueOf(t)
),
(ScopedConverter<LocalDate, U>) converter,
c -> new DefaultDateBinding<>(DATE, c)
@ -386,8 +386,8 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
return (Binding<T, U>) new DelegatingBinding<>(
(DataType<LocalDateTime>) dataType,
ScopedConverter.ofNullable(Timestamp.class, LocalDateTime.class,
(BiFunction<Timestamp, ConverterScope, LocalDateTime> & Serializable) (t, x) -> t.toLocalDateTime(),
(BiFunction<LocalDateTime, ConverterScope, Timestamp> & Serializable) (t, x) -> Timestamp.valueOf(t)
(BiFunction<Timestamp, ConverterContext, LocalDateTime> & Serializable) (t, x) -> t.toLocalDateTime(),
(BiFunction<LocalDateTime, ConverterContext, Timestamp> & Serializable) (t, x) -> Timestamp.valueOf(t)
),
(ScopedConverter<LocalDateTime, U>) converter,
c -> new DefaultTimestampBinding<>(TIMESTAMP, c)
@ -396,8 +396,8 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
return (Binding<T, U>) new DelegatingBinding<>(
(DataType<LocalTime>) dataType,
ScopedConverter.ofNullable(Time.class, LocalTime.class,
(BiFunction<Time, ConverterScope, LocalTime> & Serializable) (t, x) -> t.toLocalTime(),
(BiFunction<LocalTime, ConverterScope, Time> & Serializable) (t, x) -> Time.valueOf(t)
(BiFunction<Time, ConverterContext, LocalTime> & Serializable) (t, x) -> t.toLocalTime(),
(BiFunction<LocalTime, ConverterContext, Time> & Serializable) (t, x) -> Time.valueOf(t)
),
(ScopedConverter<LocalTime, U>) converter,
c -> new DefaultTimeBinding<>(TIME, c)
@ -430,8 +430,8 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
return (Binding<T, U>) new DelegatingBinding<>(
(DataType<UByte>) dataType,
ScopedConverter.ofNullable(Short.class, UByte.class,
(BiFunction<Short, ConverterScope, UByte> & Serializable) (t, x) -> UByte.valueOf(t),
(BiFunction<UByte, ConverterScope, Short> & Serializable) (t, x) -> t.shortValue()
(BiFunction<Short, ConverterContext, UByte> & Serializable) (t, x) -> UByte.valueOf(t),
(BiFunction<UByte, ConverterContext, Short> & Serializable) (t, x) -> t.shortValue()
),
(ScopedConverter<UByte, U>) converter,
c -> new DefaultShortBinding<>(SMALLINT, c)
@ -440,8 +440,8 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
return (Binding<T, U>) new DelegatingBinding<>(
(DataType<UInteger>) dataType,
ScopedConverter.ofNullable(Long.class, UInteger.class,
(BiFunction<Long, ConverterScope, UInteger> & Serializable) (t, x) -> UInteger.valueOf(t),
(BiFunction<UInteger, ConverterScope, Long> & Serializable) (t, x) -> t.longValue()
(BiFunction<Long, ConverterContext, UInteger> & Serializable) (t, x) -> UInteger.valueOf(t),
(BiFunction<UInteger, ConverterContext, Long> & Serializable) (t, x) -> t.longValue()
),
(ScopedConverter<UInteger, U>) converter,
c -> new DefaultLongBinding<>(BIGINT, c)
@ -450,8 +450,8 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
return (Binding<T, U>) new DelegatingBinding<>(
(DataType<ULong>) dataType,
ScopedConverter.ofNullable(BigInteger.class, ULong.class,
(BiFunction<BigInteger, ConverterScope, ULong> & Serializable) (t, x) -> ULong.valueOf(t),
(BiFunction<ULong, ConverterScope, BigInteger> & Serializable) (t, x) -> t.toBigInteger()
(BiFunction<BigInteger, ConverterContext, ULong> & Serializable) (t, x) -> ULong.valueOf(t),
(BiFunction<ULong, ConverterContext, BigInteger> & Serializable) (t, x) -> t.toBigInteger()
),
(ScopedConverter<ULong, U>) converter,
c -> new DefaultBigIntegerBinding<>(DECIMAL_INTEGER, c)
@ -460,8 +460,8 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
return (Binding<T, U>) new DelegatingBinding<>(
(DataType<UShort>) dataType,
ScopedConverter.ofNullable(Integer.class, UShort.class,
(BiFunction<Integer, ConverterScope, UShort> & Serializable) (t, x) -> UShort.valueOf(t),
(BiFunction<UShort, ConverterScope, Integer> & Serializable) (t, x) -> t.intValue()
(BiFunction<Integer, ConverterContext, UShort> & Serializable) (t, x) -> UShort.valueOf(t),
(BiFunction<UShort, ConverterContext, Integer> & Serializable) (t, x) -> t.intValue()
),
(ScopedConverter<UShort, U>) converter,
c -> new DefaultIntegerBinding<>(INTEGER, c)
@ -940,7 +940,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
public final void sql(BindingSQLContext<U> ctx) throws SQLException {
T converted = converter().to(ctx.value(), ctx.converterScope());
T converted = converter().to(ctx.value(), ctx.converterContext());
// Casting can be enforced or prevented
switch (ctx.render().castMode()) {
@ -1000,7 +1000,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
public final void set(BindingSetStatementContext<U> ctx) throws SQLException {
T value = converter().to(ctx.value(), ctx.converterScope());
T value = converter().to(ctx.value(), ctx.converterContext());
if (!FALSE.equals(ctx.settings().isExecuteLogging()))
if (log.isTraceEnabled())
@ -1017,7 +1017,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
public final void set(BindingSetSQLOutputContext<U> ctx) throws SQLException {
T value = converter().to(ctx.value(), ctx.converterScope());
T value = converter().to(ctx.value(), ctx.converterContext());
if (value == null)
ctx.output().writeObject(null);
@ -1027,7 +1027,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
public final void get(BindingGetResultSetContext<U> ctx) throws SQLException {
U value = converter().from(get0(ctx), ctx.converterScope());
U value = converter().from(get0(ctx), ctx.converterContext());
if (attachable)
value = attach(value, ctx.configuration());
@ -1037,7 +1037,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
public final void get(BindingGetStatementContext<U> ctx) throws SQLException {
U value = converter().from(get0(ctx), ctx.converterScope());
U value = converter().from(get0(ctx), ctx.converterContext());
if (attachable)
value = attach(value, ctx.configuration());
@ -1047,7 +1047,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
public final void get(BindingGetSQLInputContext<U> ctx) throws SQLException {
U value = converter().from(get0(ctx), ctx.converterScope());
U value = converter().from(get0(ctx), ctx.converterContext());
if (attachable)
value = attach(value, ctx.configuration());
@ -1129,17 +1129,17 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final void sqlInline0(BindingSQLContext<U> ctx, X value) throws SQLException {
delegatingBinding.sqlInline0(ctx, delegatingConverter.to(value, ctx.converterScope()));
delegatingBinding.sqlInline0(ctx, delegatingConverter.to(value, ctx.converterContext()));
}
@Override
final void sqlBind0(BindingSQLContext<U> ctx, X value) throws SQLException {
delegatingBinding.sqlBind0(ctx, delegatingConverter.to(value, ctx.converterScope()));
delegatingBinding.sqlBind0(ctx, delegatingConverter.to(value, ctx.converterContext()));
}
@Override
final void set0(BindingSetStatementContext<U> ctx, X value) throws SQLException {
delegatingBinding.set0(ctx, delegatingConverter.to(value, ctx.converterScope()));
delegatingBinding.set0(ctx, delegatingConverter.to(value, ctx.converterContext()));
}
@Override
@ -1149,22 +1149,22 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final void set0(BindingSetSQLOutputContext<U> ctx, X value) throws SQLException {
delegatingBinding.set0(ctx, delegatingConverter.to(value, ctx.converterScope()));
delegatingBinding.set0(ctx, delegatingConverter.to(value, ctx.converterContext()));
}
@Override
final X get0(BindingGetResultSetContext<U> ctx) throws SQLException {
return delegatingConverter.from(delegatingBinding.get0(ctx), ctx.converterScope());
return delegatingConverter.from(delegatingBinding.get0(ctx), ctx.converterContext());
}
@Override
final X get0(BindingGetStatementContext<U> ctx) throws SQLException {
return delegatingConverter.from(delegatingBinding.get0(ctx), ctx.converterScope());
return delegatingConverter.from(delegatingBinding.get0(ctx), ctx.converterContext());
}
@Override
final X get0(BindingGetSQLInputContext<U> ctx) throws SQLException {
return delegatingConverter.from(delegatingBinding.get0(ctx), ctx.converterScope());
return delegatingConverter.from(delegatingBinding.get0(ctx), ctx.converterContext());
}
@Override
@ -3463,8 +3463,8 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
private static final ScopedConverter<OffsetDateTime, Instant> CONVERTER = ScopedConverter.ofNullable(
OffsetDateTime.class,
Instant.class,
(BiFunction<OffsetDateTime, ConverterScope, Instant> & Serializable) (t, x) -> t.toInstant(),
(BiFunction<Instant, ConverterScope, OffsetDateTime> & Serializable) (i, x) -> OffsetDateTime.ofInstant(i, ZoneOffset.UTC)
(BiFunction<OffsetDateTime, ConverterContext, Instant> & Serializable) (t, x) -> t.toInstant(),
(BiFunction<Instant, ConverterContext, OffsetDateTime> & Serializable) (i, x) -> OffsetDateTime.ofInstant(i, ZoneOffset.UTC)
);
private final DefaultOffsetDateTimeBinding<U> delegate;
@ -3482,32 +3482,32 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final void sqlInline0(BindingSQLContext<U> ctx, Instant value) throws SQLException {
delegate.sqlInline0(ctx, CONVERTER.to(value, ctx.converterScope()));
delegate.sqlInline0(ctx, CONVERTER.to(value, ctx.converterContext()));
}
@Override
final void set0(BindingSetStatementContext<U> ctx, Instant value) throws SQLException {
delegate.set0(ctx, CONVERTER.to(value, ctx.converterScope()));
delegate.set0(ctx, CONVERTER.to(value, ctx.converterContext()));
}
@Override
final void set0(BindingSetSQLOutputContext<U> ctx, Instant value) throws SQLException {
delegate.set0(ctx, CONVERTER.to(value, ctx.converterScope()));
delegate.set0(ctx, CONVERTER.to(value, ctx.converterContext()));
}
@Override
final Instant get0(BindingGetResultSetContext<U> ctx) throws SQLException {
return CONVERTER.from(delegate.get0(ctx), ctx.converterScope());
return CONVERTER.from(delegate.get0(ctx), ctx.converterContext());
}
@Override
final Instant get0(BindingGetStatementContext<U> ctx) throws SQLException {
return CONVERTER.from(delegate.get0(ctx), ctx.converterScope());
return CONVERTER.from(delegate.get0(ctx), ctx.converterContext());
}
@Override
final Instant get0(BindingGetSQLInputContext<U> ctx) throws SQLException {
return CONVERTER.from(delegate.get0(ctx), ctx.converterScope());
return CONVERTER.from(delegate.get0(ctx), ctx.converterContext());
}
@Override
@ -3856,88 +3856,88 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
else if (type == Blob.class)
; // Not supported
else if (type == Boolean.class)
return converter.from((T) Convert.convert(string, Boolean.class), ctx.converterScope());
return converter.from((T) Convert.convert(string, Boolean.class), ctx.converterContext());
else if (type == BigInteger.class)
return converter.from((T) new BigInteger(string), ctx.converterScope());
return converter.from((T) new BigInteger(string), ctx.converterContext());
else if (type == BigDecimal.class)
return converter.from((T) new BigDecimal(string), ctx.converterScope());
return converter.from((T) new BigDecimal(string), ctx.converterContext());
else if (type == Byte.class)
return converter.from((T) Byte.valueOf(string), ctx.converterScope());
return converter.from((T) Byte.valueOf(string), ctx.converterContext());
else if (type == byte[].class)
return converter.from((T) PostgresUtils.toBytes(string), ctx.converterScope());
return converter.from((T) PostgresUtils.toBytes(string), ctx.converterContext());
else if (type == Clob.class)
; // Not supported
else if (type == Date.class)
return converter.from((T) Date.valueOf(string), ctx.converterScope());
return converter.from((T) Date.valueOf(string), ctx.converterContext());
else if (type == Double.class)
return converter.from((T) Double.valueOf(string), ctx.converterScope());
return converter.from((T) Double.valueOf(string), ctx.converterContext());
else if (type == Float.class)
return converter.from((T) Float.valueOf(string), ctx.converterScope());
return converter.from((T) Float.valueOf(string), ctx.converterContext());
else if (type == Integer.class)
return converter.from((T) Integer.valueOf(string), ctx.converterScope());
return converter.from((T) Integer.valueOf(string), ctx.converterContext());
else if (type == Long.class)
return converter.from((T) Long.valueOf(string), ctx.converterScope());
return converter.from((T) Long.valueOf(string), ctx.converterContext());
else if (type == Short.class)
return converter.from((T) Short.valueOf(string), ctx.converterScope());
return converter.from((T) Short.valueOf(string), ctx.converterContext());
else if (type == String.class)
return converter.from((T) string, ctx.converterScope());
return converter.from((T) string, ctx.converterContext());
else if (type == Time.class)
return converter.from((T) Time.valueOf(string), ctx.converterScope());
return converter.from((T) Time.valueOf(string), ctx.converterContext());
else if (type == Timestamp.class)
return converter.from((T) Timestamp.valueOf(patchIso8601Timestamp(string, false)), ctx.converterScope());
return converter.from((T) Timestamp.valueOf(patchIso8601Timestamp(string, false)), ctx.converterContext());
else if (type == LocalTime.class)
return converter.from((T) LocalTime.parse(string), ctx.converterScope());
return converter.from((T) LocalTime.parse(string), ctx.converterContext());
else if (type == LocalDate.class)
return converter.from((T) LocalDate.parse(string), ctx.converterScope());
return converter.from((T) LocalDate.parse(string), ctx.converterContext());
else if (type == LocalDateTime.class)
return converter.from((T) LocalDateTime.parse(patchIso8601Timestamp(string, true)), ctx.converterScope());
return converter.from((T) LocalDateTime.parse(patchIso8601Timestamp(string, true)), ctx.converterContext());
else if (type == OffsetTime.class)
return converter.from((T) OffsetDateTimeParser.offsetTime(string), ctx.converterScope());
return converter.from((T) OffsetDateTimeParser.offsetTime(string), ctx.converterContext());
else if (type == OffsetDateTime.class)
return converter.from((T) OffsetDateTimeParser.offsetDateTime(string), ctx.converterScope());
return converter.from((T) OffsetDateTimeParser.offsetDateTime(string), ctx.converterContext());
else if (type == Instant.class)
return converter.from((T) OffsetDateTimeParser.offsetDateTime(string).toInstant(), ctx.converterScope());
return converter.from((T) OffsetDateTimeParser.offsetDateTime(string).toInstant(), ctx.converterContext());
else if (type == JSON.class)
return converter.from((T) JSON.json(string), ctx.converterScope());
return converter.from((T) JSON.json(string), ctx.converterContext());
else if (type == JSONB.class)
return converter.from((T) JSONB.jsonb(string), ctx.converterScope());
return converter.from((T) JSONB.jsonb(string), ctx.converterContext());
else if (type == UByte.class)
return converter.from((T) UByte.valueOf(string), ctx.converterScope());
return converter.from((T) UByte.valueOf(string), ctx.converterContext());
else if (type == UShort.class)
return converter.from((T) UShort.valueOf(string), ctx.converterScope());
return converter.from((T) UShort.valueOf(string), ctx.converterContext());
else if (type == UInteger.class)
return converter.from((T) UInteger.valueOf(string), ctx.converterScope());
return converter.from((T) UInteger.valueOf(string), ctx.converterContext());
else if (type == ULong.class)
return converter.from((T) ULong.valueOf(string), ctx.converterScope());
return converter.from((T) ULong.valueOf(string), ctx.converterContext());
else if (type == UUID.class)
return converter.from((T) UUID.fromString(string), ctx.converterScope());
return converter.from((T) UUID.fromString(string), ctx.converterContext());
else if (type == XML.class)
return converter.from((T) XML.xml(string), ctx.converterScope());
return converter.from((T) XML.xml(string), ctx.converterContext());
else if (type.isArray())
return converter.from((T) pgNewArray(ctx, field, type, string), ctx.converterScope());
return converter.from((T) pgNewArray(ctx, field, type, string), ctx.converterContext());
else if (EnumType.class.isAssignableFrom(type))
return converter.from((T) DefaultEnumTypeBinding.getEnumType((Class<EnumType>) type, string), ctx.converterScope());
return converter.from((T) DefaultEnumTypeBinding.getEnumType((Class<EnumType>) type, string), ctx.converterContext());
else if (Result.class.isAssignableFrom(type))
if (string.startsWith("<"))
return converter.from((T) readMultisetXML(ctx, (AbstractRow<Record>) field.getDataType().getRow(), (Class<Record>) field.getDataType().getRecordType(), string), ctx.converterScope());
return converter.from((T) readMultisetXML(ctx, (AbstractRow<Record>) field.getDataType().getRow(), (Class<Record>) field.getDataType().getRecordType(), string), ctx.converterContext());
else
return converter.from((T) readMultisetJSON(ctx, (AbstractRow<Record>) field.getDataType().getRow(), (Class<Record>) field.getDataType().getRecordType(), string), ctx.converterScope());
return converter.from((T) readMultisetJSON(ctx, (AbstractRow<Record>) field.getDataType().getRow(), (Class<Record>) field.getDataType().getRecordType(), string), ctx.converterContext());
else if (Record.class.isAssignableFrom(type)
// [#11812] UDTRecords/TableRecords or InternalRecords that don't have an explicit converter
&& (!InternalRecord.class.isAssignableFrom(type) || type == converter.fromType()))
return converter.from((T) pgNewRecord(ctx, type, (AbstractRow<?>) field.getDataType().getRow(), string), ctx.converterScope());
return converter.from((T) pgNewRecord(ctx, type, (AbstractRow<?>) field.getDataType().getRow(), string), ctx.converterContext());
else if (type == Object.class)
return converter.from((T) string, ctx.converterScope());
return converter.from((T) string, ctx.converterContext());
// [#4964] [#6058] Recurse only if we have a meaningful converter, not the identity converter,
// which would cause a StackOverflowError, here!
else if (type != wrapper(converter.toType())) {
return converter.from((T) pgFromString(ctx, field("converted_field", ((ConvertedDataType<?, ?>) field.getDataType()).delegate()), string), ctx.converterScope());
return converter.from((T) pgFromString(ctx, field("converted_field", ((ConvertedDataType<?, ?>) field.getDataType()).delegate()), string), ctx.converterContext());
}
throw new UnsupportedOperationException("Class " + type + " is not supported");
@ -5416,7 +5416,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
void sqlInline0(BindingSQLContext<U> ctx, JSONB value) throws SQLException {
if (EMULATE_AS_BLOB.contains(ctx.dialect())) {
bytes(ctx.configuration()).sqlInline0(ctx, bytesConverter(ctx.configuration()).to(value, ctx.converterScope()));
bytes(ctx.configuration()).sqlInline0(ctx, bytesConverter(ctx.configuration()).to(value, ctx.converterContext()));
}
else {
super.sqlInline0(ctx, value);
@ -5437,7 +5437,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final void set0(BindingSetStatementContext<U> ctx, JSONB value) throws SQLException {
if (EMULATE_AS_BLOB.contains(ctx.dialect()))
bytes(ctx.configuration()).set0(ctx, bytesConverter(ctx.configuration()).to(value, ctx.converterScope()));
bytes(ctx.configuration()).set0(ctx, bytesConverter(ctx.configuration()).to(value, ctx.converterContext()));
else
ctx.statement().setString(ctx.index(), value.data());
}
@ -5445,7 +5445,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final void set0(BindingSetSQLOutputContext<U> ctx, JSONB value) throws SQLException {
if (EMULATE_AS_BLOB.contains(ctx.dialect()))
bytes(ctx.configuration()).set0(ctx, bytesConverter(ctx.configuration()).to(value, ctx.converterScope()));
bytes(ctx.configuration()).set0(ctx, bytesConverter(ctx.configuration()).to(value, ctx.converterContext()));
else
ctx.output().writeString(value.data());
}
@ -5453,7 +5453,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final JSONB get0(BindingGetResultSetContext<U> ctx) throws SQLException {
if (EMULATE_AS_BLOB.contains(ctx.dialect()))
return bytesConverter(ctx.configuration()).from(bytes(ctx.configuration()).get0(ctx), ctx.converterScope());
return bytesConverter(ctx.configuration()).from(bytes(ctx.configuration()).get0(ctx), ctx.converterContext());
String string = ctx.resultSet().getString(ctx.index());
return string == null ? null : JSONB.valueOf(string);
@ -5462,7 +5462,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final JSONB get0(BindingGetStatementContext<U> ctx) throws SQLException {
if (EMULATE_AS_BLOB.contains(ctx.dialect()))
return bytesConverter(ctx.configuration()).from(bytes(ctx.configuration()).get0(ctx), ctx.converterScope());
return bytesConverter(ctx.configuration()).from(bytes(ctx.configuration()).get0(ctx), ctx.converterContext());
String string = ctx.statement().getString(ctx.index());
return string == null ? null : JSONB.valueOf(string);
@ -5471,7 +5471,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
@Override
final JSONB get0(BindingGetSQLInputContext<U> ctx) throws SQLException {
if (EMULATE_AS_BLOB.contains(ctx.dialect()))
return bytesConverter(ctx.configuration()).from(bytes(ctx.configuration()).get0(ctx), ctx.converterScope());
return bytesConverter(ctx.configuration()).from(bytes(ctx.configuration()).get0(ctx), ctx.converterContext());
String string = ctx.input().readString();
return string == null ? null : JSONB.valueOf(string);

View File

@ -103,7 +103,7 @@ class DefaultBindingGetResultSetContext<U> extends AbstractExecuteScope implemen
return new DefaultBindingGetResultSetContext<T>(ctx, resultSet, index) {
@Override
public void value(T v) {
outer.value(scoped(converter).from(v, converterScope()));
outer.value(scoped(converter).from(v, converterContext()));
}
};
}

View File

@ -80,7 +80,7 @@ class DefaultBindingGetSQLInputContext<U> extends AbstractExecuteScope implement
return new DefaultBindingGetSQLInputContext<T>(ctx, input) {
@Override
public void value(T v) {
outer.value(scoped(converter).from(v, converterScope()));
outer.value(scoped(converter).from(v, converterContext()));
}
};
}

View File

@ -88,7 +88,7 @@ class DefaultBindingGetStatementContext<U> extends AbstractExecuteScope implemen
return new DefaultBindingGetStatementContext<T>(ctx, statement, index) {
@Override
public void value(T v) {
outer.value(scoped(converter).from(v, converterScope()));
outer.value(scoped(converter).from(v, converterContext()));
}
};
}

View File

@ -44,7 +44,7 @@ import java.util.Map;
import org.jooq.BindingSQLContext;
import org.jooq.Configuration;
import org.jooq.Converter;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
import org.jooq.RenderContext;
/**
@ -69,8 +69,8 @@ class DefaultBindingSQLContext<U> extends AbstractScope implements BindingSQLCon
}
@Override
public final ConverterScope converterScope() {
return render.converterScope();
public final ConverterContext converterContext() {
return render.converterContext();
}
@Override
@ -90,7 +90,7 @@ class DefaultBindingSQLContext<U> extends AbstractScope implements BindingSQLCon
@Override
public <T> BindingSQLContext<T> convert(Converter<? extends T, ? super U> converter) {
return new DefaultBindingSQLContext<>(configuration, data, render, scoped(converter).to(value, converterScope()), variable);
return new DefaultBindingSQLContext<>(configuration, data, render, scoped(converter).to(value, converterContext()), variable);
}
@Override

View File

@ -72,7 +72,7 @@ class DefaultBindingSetSQLOutputContext<U> extends AbstractExecuteScope implemen
@Override
public final <T> BindingSetSQLOutputContext<T> convert(Converter<? extends T, ? super U> converter) {
return new DefaultBindingSetSQLOutputContext<>(ctx, output, scoped(converter).to(value, converterScope()));
return new DefaultBindingSetSQLOutputContext<>(ctx, output, scoped(converter).to(value, converterContext()));
}
@Override

View File

@ -79,7 +79,7 @@ class DefaultBindingSetStatementContext<U> extends AbstractExecuteScope implemen
@Override
public final <T> BindingSetStatementContext<T> convert(Converter<? extends T, ? super U> converter) {
return new DefaultBindingSetStatementContext<>(ctx, statement, index, scoped(converter).to(value, converterScope()));
return new DefaultBindingSetStatementContext<>(ctx, statement, index, scoped(converter).to(value, converterContext()));
}
@Override

View File

@ -40,18 +40,18 @@ package org.jooq.impl;
import java.util.Map;
import org.jooq.Configuration;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
/**
* @author Lukas Eder
*/
final class DefaultConverterScope extends AbstractScope implements ConverterScope {
final class DefaultConverterContext extends AbstractScope implements ConverterContext {
DefaultConverterScope(Configuration configuration) {
DefaultConverterContext(Configuration configuration) {
super(configuration, new DataMap());
}
DefaultConverterScope(Configuration configuration, Map<Object, Object> data) {
DefaultConverterContext(Configuration configuration, Map<Object, Object> data) {
super(configuration, data);
}
}

View File

@ -61,7 +61,7 @@ import java.util.Map;
import org.jooq.Configuration;
import org.jooq.ConnectionProvider;
import org.jooq.Constants;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
import org.jooq.DDLQuery;
import org.jooq.DSLContext;
import org.jooq.Delete;
@ -95,7 +95,7 @@ class DefaultExecuteContext implements ExecuteContext {
private static final JooqLogger log = JooqLogger.getLogger(DefaultExecuteContext.class);
// Persistent attributes (repeatable)
private final ConverterScope converterScope;
private final ConverterContext converterContext;
private final Instant creationTime;
private final Configuration originalConfiguration;
private final Configuration derivedConfiguration;
@ -337,7 +337,7 @@ class DefaultExecuteContext implements ExecuteContext {
this.data = new DataMap();
this.query = query;
this.routine = routine;
this.converterScope = new DefaultConverterScope(derivedConfiguration, data);
this.converterContext = new DefaultConverterContext(derivedConfiguration, data);
if (routine != null) {
this.batch = false;
@ -370,8 +370,8 @@ class DefaultExecuteContext implements ExecuteContext {
}
@Override
public final ConverterScope converterScope() {
return converterScope;
public final ConverterContext converterContext() {
return converterContext;
}
@Override

View File

@ -37,7 +37,7 @@
*/
package org.jooq.impl;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
import org.jooq.ScopedConverter;
/**
@ -54,7 +54,7 @@ public class DelegatingConverter<T, U> extends AbstractScopedConverter<T, U> {
}
@Override
public final U from(T t, ConverterScope scope) {
public final U from(T t, ConverterContext scope) {
return delegate.from(t, scope);
}
@ -64,7 +64,7 @@ public class DelegatingConverter<T, U> extends AbstractScopedConverter<T, U> {
}
@Override
public final T to(U u, ConverterScope scope) {
public final T to(U u, ConverterContext scope) {
return delegate.to(u, scope);
}

View File

@ -38,14 +38,14 @@
package org.jooq.impl;
import static org.jooq.impl.Convert.convert;
import static org.jooq.impl.Internal.converterScope;
import static org.jooq.impl.Internal.converterContext;
import static org.jooq.tools.reflect.Reflect.wrapper;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Function;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
/**
* A base class for enum conversion.

View File

@ -38,7 +38,7 @@
package org.jooq.impl;
import org.jooq.Converter;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
import org.jooq.ScopedConverter;
/**
@ -54,12 +54,12 @@ public final class IdentityConverter<T> implements ScopedConverter<T, T> {
}
@Override
public final T from(T t, ConverterScope scope) {
public final T from(T t, ConverterContext scope) {
return t;
}
@Override
public final T to(T t, ConverterScope scope) {
public final T to(T t, ConverterContext scope) {
return t;
}

View File

@ -53,7 +53,7 @@ import org.jooq.Binding;
import org.jooq.Check;
import org.jooq.Comment;
import org.jooq.Converter;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
import org.jooq.DDLExportConfiguration;
import org.jooq.DataType;
import org.jooq.Domain;
@ -630,9 +630,9 @@ public final class Internal {
return 0x7FFFFFF & object.hashCode();
}
private static final ConverterScope CONVERTER_SCOPE = new DefaultConverterScope(CONFIG);
private static final ConverterContext CONVERTER_SCOPE = new DefaultConverterContext(CONFIG);
public static final ConverterScope converterScope() {
public static final ConverterContext converterContext() {
return CONVERTER_SCOPE;
}
}

View File

@ -41,7 +41,7 @@ import java.lang.reflect.Method;
import jakarta.persistence.AttributeConverter;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
import org.jooq.exception.MappingException;
import org.jooq.tools.JooqLogger;
import org.jooq.tools.reflect.Reflect;
@ -117,12 +117,12 @@ public final class JPAConverter<T, U> extends AbstractScopedConverter<T, U> {
}
@Override
public final U from(T t, ConverterScope scope) {
public final U from(T t, ConverterContext scope) {
return delegate.convertToEntityAttribute(t);
}
@Override
public final T to(U u, ConverterScope scope) {
public final T to(U u, ConverterContext scope) {
return delegate.convertToDatabaseColumn(u);
}
}

View File

@ -37,7 +37,7 @@
*/
package org.jooq.impl;
import static org.jooq.impl.Internal.converterScope;
import static org.jooq.impl.Internal.converterContext;
import org.jooq.Binding;
import org.jooq.Configuration;
@ -99,7 +99,7 @@ final class LegacyConvertedDataType<T, U> extends DefaultDataType<U> {
// [#3200] Try to convert arbitrary objects to T
else
return ((ScopedConverter<T, U>) getConverter()).from(delegate.convert(object), converterScope());
return ((ScopedConverter<T, U>) getConverter()).from(delegate.convert(object), converterContext());
}
@SuppressWarnings({ "unchecked", "rawtypes" })

View File

@ -44,7 +44,7 @@ import static org.jooq.impl.Internal.subscriber;
import static org.jooq.impl.Tools.EMPTY_PARAM;
import static org.jooq.impl.Tools.abstractDMLQuery;
import static org.jooq.impl.Tools.abstractResultQuery;
import static org.jooq.impl.Tools.converterScope;
import static org.jooq.impl.Tools.converterContext;
import static org.jooq.impl.Tools.fields;
import static org.jooq.impl.Tools.recordFactory;
import static org.jooq.impl.Tools.translate;
@ -1240,7 +1240,7 @@ final class R2DBC {
if (converter == null)
throw new DataTypeException("Cannot convert from " + o.getClass() + " to " + uType + ". Please report an issue here: https://github.com/jOOQ/jOOQ/issues/new. As a workaround, you can implement a ConverterProvider.");
else
return scoped(converter).from(o, converterScope(c));
return scoped(converter).from(o, converterContext(c));
}
// ---------------------------------------------------------------------

View File

@ -46,7 +46,7 @@ import java.util.Map;
import org.jooq.Configuration;
import org.jooq.ConnectionProvider;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
import org.jooq.ExecuteContext;
import org.jooq.ExecuteType;
import org.jooq.Query;
@ -68,8 +68,8 @@ final class SimpleExecuteContext extends AbstractScope implements ExecuteContext
}
@Override
public final ConverterScope converterScope() {
return Tools.converterScope(configuration);
public final ConverterContext converterContext() {
return Tools.converterContext(configuration);
}
@Override

View File

@ -42,7 +42,7 @@ import java.time.LocalTime;
import java.util.function.Function;
import org.jooq.Converter;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
/**
* @author Lukas Eder
@ -59,12 +59,12 @@ public final class TimeToLocalTimeConverter extends AbstractScopedConverter<Time
}
@Override
public final LocalTime from(Time t, ConverterScope scope) {
public final LocalTime from(Time t, ConverterContext scope) {
return t == null ? null : t.toLocalTime();
}
@Override
public final Time to(LocalTime u, ConverterScope scope) {
public final Time to(LocalTime u, ConverterContext scope) {
return u == null ? null : Time.valueOf(u);
}
}

View File

@ -39,7 +39,7 @@ package org.jooq.impl;
import java.sql.Timestamp;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
/**
* @author Lukas Eder
@ -53,12 +53,12 @@ final class TimestampToJavaUtilDateConverter extends AbstractScopedConverter<Tim
}
@Override
public final java.util.Date from(Timestamp t, ConverterScope scope) {
public final java.util.Date from(Timestamp t, ConverterContext scope) {
return t == null ? null : new java.util.Date(t.getTime());
}
@Override
public final Timestamp to(java.util.Date u, ConverterScope scope) {
public final Timestamp to(java.util.Date u, ConverterContext scope) {
return u == null ? null : new Timestamp(u.getTime());
}
}

View File

@ -42,7 +42,7 @@ import java.time.LocalDateTime;
import java.util.function.Function;
import org.jooq.Converter;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
/**
* @author Lukas Eder
@ -59,12 +59,12 @@ public final class TimestampToLocalDateTimeConverter extends AbstractScopedConve
}
@Override
public final LocalDateTime from(Timestamp t, ConverterScope scope) {
public final LocalDateTime from(Timestamp t, ConverterContext scope) {
return t == null ? null : t.toLocalDateTime();
}
@Override
public final Timestamp to(LocalDateTime u, ConverterScope scope) {
public final Timestamp to(LocalDateTime u, ConverterContext scope) {
return u == null ? null : Timestamp.valueOf(u);
}
}

View File

@ -263,7 +263,7 @@ import org.jooq.Configuration;
import org.jooq.Context;
import org.jooq.Converter;
import org.jooq.ConverterProvider;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
import org.jooq.Converters;
import org.jooq.Cursor;
import org.jooq.DSLContext;
@ -7104,11 +7104,11 @@ final class Tools {
return dataType;
}
static final ConverterScope converterScope(Attachable attachable) {
return new DefaultConverterScope(configuration(attachable));
static final ConverterContext converterContext(Attachable attachable) {
return new DefaultConverterContext(configuration(attachable));
}
static final ConverterScope converterScope(Configuration configuration) {
return new DefaultConverterScope(configuration(configuration));
static final ConverterContext converterContext(Configuration configuration) {
return new DefaultConverterContext(configuration(configuration));
}
}

View File

@ -40,7 +40,7 @@ package org.jooq.impl;
import java.io.StringReader;
import java.io.StringWriter;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
import org.jooq.XML;
import jakarta.xml.bind.JAXB;

View File

@ -42,7 +42,7 @@ import static java.time.temporal.ChronoField.MILLI_OF_DAY;
import static java.time.temporal.ChronoField.MILLI_OF_SECOND;
import static org.jooq.ScopedConverter.scoped;
import static org.jooq.impl.Internal.arrayType;
import static org.jooq.impl.Internal.converterScope;
import static org.jooq.impl.Internal.converterContext;
import static org.jooq.tools.reflect.Reflect.accessible;
import static org.jooq.tools.reflect.Reflect.wrapper;
import static org.jooq.types.Unsigned.ubyte;
@ -93,7 +93,7 @@ import jakarta.xml.bind.JAXB;
// ...
import org.jooq.Converter;
import org.jooq.ConverterProvider;
import org.jooq.ConverterScope;
import org.jooq.ConverterContext;
import org.jooq.DataType;
import org.jooq.EnumType;
import org.jooq.Field;
@ -377,7 +377,7 @@ public final class Convert {
}
public static final <U> U[] convertCollection(Collection from, Class<? extends U[]> to){
return new ConvertAll<U[]>(to).from(from, converterScope());
return new ConvertAll<U[]>(to).from(from, converterContext());
}
/**
@ -407,10 +407,10 @@ public final class Convert {
Class<T> fromType = converter.fromType();
if (fromType == Object.class)
return scoped(converter).from((T) from, converterScope());
return scoped(converter).from((T) from, converterContext());
ConvertAll<T> convertAll = new ConvertAll<>(fromType);
return scoped(converter).from(convertAll.from(from, converterScope()), converterScope());
return scoped(converter).from(convertAll.from(from, converterContext()), converterContext());
}
/**
@ -521,7 +521,7 @@ public final class Convert {
List<U> result = new ArrayList<>(collection.size());
for (Object o : collection)
result.add(convert(all.from(o, converterScope()), converter));
result.add(convert(all.from(o, converterContext()), converter));
return result;
}
@ -547,7 +547,7 @@ public final class Convert {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public U from(Object from, ConverterScope scope) {
public U from(Object from, ConverterContext scope) {
if (from == null) {
// [#936] If types are converted to primitives, the result must not
@ -1249,7 +1249,7 @@ public final class Convert {
}
@Override
public Object to(U to, ConverterScope scope) {
public Object to(U to, ConverterContext scope) {
return to;
}

View File

@ -39,7 +39,7 @@ package org.jooq.tools.jdbc;
import static org.jooq.SQLDialect.DEFAULT;
import static org.jooq.ScopedConverter.scoped;
import static org.jooq.impl.Internal.converterScope;
import static org.jooq.impl.Internal.converterContext;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@ -461,7 +461,7 @@ public class MockResultSet extends JDBC41ResultSet implements ResultSet, Seriali
.converterProvider()
.provide(value == null ? Object.class : (Class<Object>) value.getClass(), type);
T converted = converter == null ? null : scoped(converter).from(value, converterScope());
T converted = converter == null ? null : scoped(converter).from(value, converterContext());
wasNull = (converted == null);
return converted;
}

View File

@ -38,7 +38,7 @@
package org.jooq.util.postgres;
import static java.lang.Integer.toOctalString;
import static org.jooq.impl.Internal.converterScope;
import static org.jooq.impl.Internal.converterContext;
import static org.jooq.tools.StringUtils.leftPad;
import java.io.ByteArrayOutputStream;
@ -531,7 +531,7 @@ public class PostgresUtils {
String separator = "";
for (int i = 0; i < r.size(); i++) {
@SuppressWarnings({ "unchecked", "rawtypes" })
Object a = ((ScopedConverter) r.field(i).getConverter()).to(r.get(i), converterScope());
Object a = ((ScopedConverter) r.field(i).getConverter()).to(r.get(i), converterContext());
sb.append(separator);
// [#753] null must not be set as a literal