Top Description Methods
org.jooq

public Interface ContextConverter<T, U>

extends Converter<T, U>
Known Direct Implementers
org.jooq.impl.AbstractContextConverter, org.jooq.impl.IdentityConverter
Static Imports
org.jooq.Converters.notImplementedBiFunction, .Converters.nullable, org.jooq.impl.Internal.converterContext

A special type of Converter with alternative from(Object, ConverterContext) and to(Object, ConverterContext) methods.

This special converter type can be used wherever an ordinary Converter is used. jOOQ internal call sites will call the alternative from(Object, ConverterContext) and to(Object, ConverterContext) methods, instead of from(Object) and to(Object), allowing for accessing global Configuration#data() content.

Method Summary

Modifier and TypeMethod and Description
public default <X> @NotNull ContextConverter<T, X>
andThen(Converter<? super U, X> converter)

Overrides default org.jooq.Converter.andThen.

Chain a converter to this converter.
public default @NotNull ContextConverter<T[], U[]>
forArrays()

Overrides default org.jooq.Converter.forArrays.

Turn this converter into a converter for arrays.
public U

Returns:

The user object.
from
(T
The database object.
databaseObject
,
ConverterContext
The context of this conversion.
ctx
)

Read and convert a database object to a user object.

public default U
from(T
The database object.
databaseObject
)

Implements org.jooq.Converter.from.

Read and convert a database object to a user object.
public static <
the database type
T
,
the user type
U
>
@NotNull ContextConverter<T, U>

Returns:

The converter.
from
(Class<T>
The database type
fromType
,
Class<U>
The user type
toType
,
BiFunction<? super T, ? super ConverterContext, ? extends U>
A function converting from T to U when reading from the database.
from
)

Construct a new read-only converter from a function.

public static <
the database type.
T
,
the user type.
U
>
@NotNull Converter<T, U>

Returns:

The converter.
fromNullable
(Class<T>
The database type.
fromType
,
Class<U>
The user type.
toType
,
BiFunction<? super T, ? super ConverterContext, ? extends U>
A function converting from T to U when reading from the database.
from
)

Construct a new read-only converter from a function.

public default @NotNull ContextConverter<U, T>
inverse()

Overrides default org.jooq.Converter.inverse.

Inverse this converter.
public static <
the database type.
T
,
the user type.
U
>
@NotNull ContextConverter<T, U>

Returns:

The converter.
of
(Class<T>
The database type.
fromType
,
Class<U>
The user type.
toType
,
BiFunction<? super T, ? super ConverterContext, ? extends U>
A function converting from T to U when reading from the database.
from
,
BiFunction<? super U, ? super ConverterContext, ? extends T>
A function converting from U to T when writing to the database.
to
)

Construct a new converter from functions.

public static <
the database type
T
,
the user type
U
>
@NotNull ContextConverter<T, U>

Returns:

The converter.
ofNullable
(Class<T>
The database type
fromType
,
Class<U>
The user type
toType
,
BiFunction<? super T, ? super ConverterContext, ? extends U>
A function converting from T to U when reading from the database.
from
,
BiFunction<? super U, ? super ConverterContext, ? extends T>
A function converting from U to T when writing to the database.
to
)

Construct a new converter from functions.

public static <T, U> @NotNull ContextConverter<T, U>
scoped(Converter<T, U> converter)

Turn a Converter into a ContextConverter.

public T

Returns:

The database object.
to
(U
The user object.
userObject
,
ConverterContext
The context of this conversion.
ctx
)

Convert and write a user object to a database object.

public default T
to(U
The user object.
userObject
)

Implements org.jooq.Converter.to.

Convert and write a user object to a database object.
public static <
the database type
T
,
the user type
U
>
@NotNull ContextConverter<T, U>

Returns:

The converter.
to
(Class<T>
The database type
fromType
,
Class<U>
The user type
toType
,
BiFunction<? super U, ? super ConverterContext, ? extends T>
A function converting from U to T when writing to the database.
to
)

Construct a new write-only converter from a function.

public static <
the database type
T
,
the user type
U
>
@NotNull Converter<T, U>

Returns:

The converter.
toNullable
(Class<T>
The database type
fromType
,
Class<U>
The user type
toType
,
BiFunction<? super U, ? super ConverterContext, ? extends T>
A function converting from U to T when writing to the database.
to
)

Construct a new write-only converter from a function.

Inherited from org.jooq.Converter:
fromfromNullablefromTypeofofNullabletotoNullabletoType

Method Detail

andThenback to summary
public default <X> @NotNull ContextConverter<T, X> andThen(Converter<? super U, X> converter)

Overrides default org.jooq.Converter.andThen.

Chain a converter to this converter.

Annotations
@Override
@NotNull
forArraysback to summary
public default @NotNull ContextConverter<T[], U[]> forArrays()

Overrides default org.jooq.Converter.forArrays.

Turn this converter into a converter for arrays.

Annotations
@Override
@NotNull
fromback to summary
public U from(T databaseObject, ConverterContext ctx)

Read and convert a database object to a user object.

Parameters
databaseObject:T

The database object.

ctx:ConverterContext

The context of this conversion.

Returns:U

The user object.

fromback to summary
public default U from(T databaseObject)

Implements org.jooq.Converter.from.

Doc from org.jooq.Converter.from.

Read and convert a database object to a user object.

Parameters
databaseObject:T

The database object.

Returns:U

The user object.

Annotations
@Override
fromback to summary
public static <T, U> @NotNull ContextConverter<T, U> from(Class<T> fromType, Class<U> toType, BiFunction<? super T, ? super ConverterContext, ? extends U> from)

Construct a new read-only converter from a function.

Parameters
<T>
the database type
<U>
the user type
fromType:Class<T>

The database type

toType:Class<U>

The user type

from:BiFunction<? super T, ? super ConverterContext, ? extends U>

A function converting from T to U when reading from the database.

Returns:@NotNull ContextConverter<T, U>

The converter.

Annotations
@NotNull
See Also
Converter
fromNullableback to summary
public static <T, U> @NotNull Converter<T, U> fromNullable(Class<T> fromType, Class<U> toType, BiFunction<? super T, ? super ConverterContext, ? extends U> from)

Construct a new read-only converter from a function.

This works like Converter#from(Class, Class, Function), except that the conversion Function is decorated with a function that always returns null for null inputs.

Example:


Converter<String, Integer> converter =
  Converter.fromNullable(String.class, Integer.class, Integer::parseInt);

// No exceptions thrown
assertNull(converter.from(null));
Parameters
<T>
the database type.
<U>
the user type.
fromType:Class<T>

The database type.

toType:Class<U>

The user type.

from:BiFunction<? super T, ? super ConverterContext, ? extends U>

A function converting from T to U when reading from the database.

Returns:@NotNull Converter<T, U>

The converter.

Annotations
@NotNull
See Also
Converter
inverseback to summary
public default @NotNull ContextConverter<U, T> inverse()

Overrides default org.jooq.Converter.inverse.

Inverse this converter.

Annotations
@Override
@NotNull
ofback to summary
public static <T, U> @NotNull ContextConverter<T, U> of(Class<T> fromType, Class<U> toType, BiFunction<? super T, ? super ConverterContext, ? extends U> from, BiFunction<? super U, ? super ConverterContext, ? extends T> to)

Construct a new converter from functions.

Parameters
<T>
the database type.
<U>
the user type.
fromType:Class<T>

The database type.

toType:Class<U>

The user type.

from:BiFunction<? super T, ? super ConverterContext, ? extends U>

A function converting from T to U when reading from the database.

to:BiFunction<? super U, ? super ConverterContext, ? extends T>

A function converting from U to T when writing to the database.

Returns:@NotNull ContextConverter<T, U>

The converter.

Annotations
@NotNull
See Also
Converter
ofNullableback to summary
public static <T, U> @NotNull ContextConverter<T, U> ofNullable(Class<T> fromType, Class<U> toType, BiFunction<? super T, ? super ConverterContext, ? extends U> from, BiFunction<? super U, ? super ConverterContext, ? extends T> to)

Construct a new converter from functions.

This works like Converter#of(Class, Class, Function, Function), except that both conversion Functions are decorated with a function that always returns null for null inputs.

Example:


Converter<String, Integer> converter =
  Converter.ofNullable(String.class, Integer.class, Integer::parseInt, Object::toString);

// No exceptions thrown
assertNull(converter.from(null));
assertNull(converter.to(null));
Parameters
<T>
the database type
<U>
the user type
fromType:Class<T>

The database type

toType:Class<U>

The user type

from:BiFunction<? super T, ? super ConverterContext, ? extends U>

A function converting from T to U when reading from the database.

to:BiFunction<? super U, ? super ConverterContext, ? extends T>

A function converting from U to T when writing to the database.

Returns:@NotNull ContextConverter<T, U>

The converter.

Annotations
@NotNull
See Also
Converter
scopedback to summary
public static <T, U> @NotNull ContextConverter<T, U> scoped(Converter<T, U> converter)

Turn a Converter into a ContextConverter.

Annotations
@NotNull
toback to summary
public T to(U userObject, ConverterContext ctx)

Convert and write a user object to a database object.

Parameters
userObject:U

The user object.

ctx:ConverterContext

The context of this conversion.

Returns:T

The database object.

toback to summary
public default T to(U userObject)

Implements org.jooq.Converter.to.

Doc from org.jooq.Converter.to.

Convert and write a user object to a database object.

Parameters
userObject:U

The user object.

Returns:T

The database object.

Annotations
@Override
toback to summary
public static <T, U> @NotNull ContextConverter<T, U> to(Class<T> fromType, Class<U> toType, BiFunction<? super U, ? super ConverterContext, ? extends T> to)

Construct a new write-only converter from a function.

Parameters
<T>
the database type
<U>
the user type
fromType:Class<T>

The database type

toType:Class<U>

The user type

to:BiFunction<? super U, ? super ConverterContext, ? extends T>

A function converting from U to T when writing to the database.

Returns:@NotNull ContextConverter<T, U>

The converter.

Annotations
@NotNull
See Also
Converter
toNullableback to summary
public static <T, U> @NotNull Converter<T, U> toNullable(Class<T> fromType, Class<U> toType, BiFunction<? super U, ? super ConverterContext, ? extends T> to)

Construct a new write-only converter from a function.

This works like Converter#to(Class, Class, Function), except that the conversion Function is decorated with a function that always returns null for null inputs.

Example:


Converter<String, Integer> converter =
  Converter.toNullable(String.class, Integer.class, Object::toString);

// No exceptions thrown
assertNull(converter.to(null));
Parameters
<T>
the database type
<U>
the user type
fromType:Class<T>

The database type

toType:Class<U>

The user type

to:BiFunction<? super U, ? super ConverterContext, ? extends T>

A function converting from U to T when writing to the database.

Returns:@NotNull Converter<T, U>

The converter.

Annotations
@NotNull
See Also
Converter