Package org.jdbi.v3.core.codec
Class CodecFactory
java.lang.Object
org.jdbi.v3.core.codec.CodecFactory
- All Implemented Interfaces:
QualifiedArgumentFactory
,QualifiedArgumentFactory.Preparable
,QualifiedColumnMapperFactory
- Direct Known Subclasses:
TypeResolvingCodecFactory
@ThreadSafe
@Alpha
public class CodecFactory
extends Object
implements QualifiedColumnMapperFactory, QualifiedArgumentFactory.Preparable
CodecFactory provides column mappers and arguments for bidirectional mapping types to database columns.
This class is immutable and thread safe.
Alpha: this class as public API is redundant with the existing way of managing mappers: we should try to combine them to make the new public API as small as possible
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jdbi.v3.core.argument.QualifiedArgumentFactory
QualifiedArgumentFactory.Preparable
-
Constructor Summary
ConstructorDescriptionCodecFactory
(Map<QualifiedType<?>, Codec<?>> codecMap) Create a new CodecFactory. -
Method Summary
Modifier and TypeMethodDescriptionbuild
(QualifiedType<?> type, Object value, ConfigRegistry config) Returns anArgument
for the given value if the factory supports it; empty otherwise.final Optional<ColumnMapper<?>>
build
(QualifiedType<?> type, ConfigRegistry config) Supplies a column mapper which will map columns to type if the factory supports it; empty otherwise.static CodecFactory.Builder
builder()
Returns a builder for fluent API.static CodecFactory
forSingleCodec
(QualifiedType<?> type, Codec<?> codec) prepare
(QualifiedType<?> type, ConfigRegistry config) final Collection<QualifiedType<?>>
-
Constructor Details
-
CodecFactory
Create a new CodecFactory.
-
-
Method Details
-
builder
Returns a builder for fluent API. -
forSingleCodec
-
prepare
public final Optional<Function<Object,Argument>> prepare(QualifiedType<?> type, ConfigRegistry config) - Specified by:
prepare
in interfaceQualifiedArgumentFactory.Preparable
-
prePreparedTypes
- Specified by:
prePreparedTypes
in interfaceQualifiedArgumentFactory.Preparable
-
build
Description copied from interface:QualifiedArgumentFactory
Returns anArgument
for the given value if the factory supports it; empty otherwise.- Specified by:
build
in interfaceQualifiedArgumentFactory
- Parameters:
type
- the known qualified type of value. Depending on the situation this may be a full generic signature e.g.ParameterizedType
, aClass
, or Object.class if no type information is known.value
- the value to convert into anArgument
config
- the config registry, for composition- Returns:
- an argument for the given value if this factory supports it, or
Optional.empty()
otherwise. - See Also:
-
build
Description copied from interface:QualifiedColumnMapperFactory
Supplies a column mapper which will map columns to type if the factory supports it; empty otherwise.- Specified by:
build
in interfaceQualifiedColumnMapperFactory
- Parameters:
type
- the target qualified type to map toconfig
- the config registry, for composition- Returns:
- a column mapper for the given type if this factory supports it, or
Optional.empty()
otherwise. - See Also:
-