Class TypeResolvingCodecFactory

java.lang.Object
org.jdbi.v3.core.codec.CodecFactory
org.jdbi.v3.guava.codec.TypeResolvingCodecFactory
All Implemented Interfaces:
QualifiedArgumentFactory, QualifiedArgumentFactory.Preparable, QualifiedColumnMapperFactory

@Beta @ThreadSafe public class TypeResolvingCodecFactory extends 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.

  • Constructor Details

    • TypeResolvingCodecFactory

      public TypeResolvingCodecFactory(Map<QualifiedType<?>,Codec<?>> codecMap)
      Create a new TypeResolvingCodecFactory.
  • Method Details

    • builder

      public static CodecFactory.Builder builder()
      Returns a builder for fluent API.
      Returns:
      A CodecFactory.Builder instance.
    • forSingleCodec

      public static CodecFactory forSingleCodec(QualifiedType<?> type, 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 invalid input: '{@link /*missing*/}' CodecFactory that will be used if the given type is requested.