Class TypeResolvingCodecFactory
java.lang.Object
org.jdbi.v3.core.codec.CodecFactory
org.jdbi.v3.guava.codec.TypeResolvingCodecFactory
- All Implemented Interfaces:
org.jdbi.v3.core.argument.QualifiedArgumentFactory, org.jdbi.v3.core.argument.QualifiedArgumentFactory.Preparable, org.jdbi.v3.core.mapper.QualifiedColumnMapperFactory
@Beta
@ThreadSafe
public class TypeResolvingCodecFactory
extends org.jdbi.v3.core.codec.CodecFactory
An extended
CodecFactory which can resolve Codecs for subtypes. This allows registering e.g. a codec for Set<String> and using any
subtype of Set which the same type parameters (e.g. a HashSet<String<) will find the right codec.
This is an experimental feature which relies on TypeToken from the Guava library.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jdbi.v3.core.codec.CodecFactory
org.jdbi.v3.core.codec.CodecFactory.BuilderNested classes/interfaces inherited from interface org.jdbi.v3.core.argument.QualifiedArgumentFactory
org.jdbi.v3.core.argument.QualifiedArgumentFactory.Preparable -
Constructor Summary
ConstructorsConstructorDescriptionTypeResolvingCodecFactory(Map<org.jdbi.v3.core.qualifier.QualifiedType<?>, org.jdbi.v3.core.codec.Codec<?>> codecMap) Create a new TypeResolvingCodecFactory. -
Method Summary
Modifier and TypeMethodDescriptionstatic org.jdbi.v3.core.codec.CodecFactory.Builderbuilder()Returns a builder for fluent API.static org.jdbi.v3.core.codec.CodecFactoryforSingleCodec(org.jdbi.v3.core.qualifier.QualifiedType<?> type, org.jdbi.v3.core.codec.Codec<?> codec) Creates aCodecFactoryfor a single type.Methods inherited from class org.jdbi.v3.core.codec.CodecFactory
build, build, prepare, prePreparedTypes
-
Constructor Details
-
TypeResolvingCodecFactory
public TypeResolvingCodecFactory(Map<org.jdbi.v3.core.qualifier.QualifiedType<?>, org.jdbi.v3.core.codec.Codec<?>> codecMap) Create a new TypeResolvingCodecFactory.
-
-
Method Details
-
builder
public static org.jdbi.v3.core.codec.CodecFactory.Builder builder()Returns a builder for fluent API.- Returns:
- A
CodecFactory.Builderinstance.
-
forSingleCodec
public static org.jdbi.v3.core.codec.CodecFactory forSingleCodec(org.jdbi.v3.core.qualifier.QualifiedType<?> type, org.jdbi.v3.core.codec.Codec<?> codec) Creates aCodecFactoryfor a single type.- Parameters:
type- The type for which the factory is created.codec- TheCodecto use.- Returns:
- A new
CodecFactorythat will be used if the given type is requested.
-