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.Builder

    Nested classes/interfaces inherited from interface org.jdbi.v3.core.argument.QualifiedArgumentFactory

    org.jdbi.v3.core.argument.QualifiedArgumentFactory.Preparable
  • Constructor Summary

    Constructors
    Constructor
    Description
    TypeResolvingCodecFactory(Map<org.jdbi.v3.core.qualifier.QualifiedType<?>, org.jdbi.v3.core.codec.Codec<?>> codecMap)
    Create a new TypeResolvingCodecFactory.
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.jdbi.v3.core.codec.CodecFactory.Builder
    Returns a builder for fluent API.
    static org.jdbi.v3.core.codec.CodecFactory
    forSingleCodec(org.jdbi.v3.core.qualifier.QualifiedType<?> type, org.jdbi.v3.core.codec.Codec<?> codec)
    Creates a CodecFactory for a single type.

    Methods inherited from class org.jdbi.v3.core.codec.CodecFactory

    build, build, prepare, prePreparedTypes

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.Builder instance.
    • 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 a CodecFactory for a single type.
      Parameters:
      type - The type for which the factory is created.
      codec - The Codec to use.
      Returns:
      A new CodecFactory that will be used if the given type is requested.