Class Mappers

java.lang.Object
org.jdbi.v3.core.mapper.Mappers
All Implemented Interfaces:
JdbiConfig<Mappers>

public class Mappers extends Object implements JdbiConfig<Mappers>
Configuration class for obtaining row or column mappers.

This configuration is merely a convenience class, and does not have any configuration of its own. All methods delegate to RowMappers or ColumnMappers.

  • Constructor Details

    • Mappers

      public Mappers()
  • Method Details

    • setRegistry

      public void setRegistry(ConfigRegistry registry)
      Description copied from interface: JdbiConfig
      The registry will inject itself into the configuration object. This can be useful if you need to look up dependencies. You will get a new registry after being copied.
      Specified by:
      setRegistry in interface JdbiConfig<Mappers>
      Parameters:
      registry - the registry that owns this configuration object
    • findFor

      public <T> Optional<RowMapper<T>> findFor(Class<T> type)
      Obtain a mapper for the given type. If a row mapper is registered for the given type, it is returned. If a column mapper is registered for the given type, it is adapted into a row mapper, mapping the first column of the result set. If neither a row or column mapper is registered, empty is returned.
      Type Parameters:
      T - the type of the mapper to find
      Parameters:
      type - the target type to map to
      Returns:
      a mapper for the given type, or empty if no row or column mapper is registered for the given type.
    • findFor

      public <T> Optional<RowMapper<T>> findFor(GenericType<T> type)
      Obtain a mapper for the given type. If a row mapper is registered for the given type, it is returned. If a column mapper is registered for the given type, it is adapted into a row mapper, mapping the first column of the result set. If neither a row or column mapper is registered, empty is returned.
      Type Parameters:
      T - the type of the mapper to find
      Parameters:
      type - the target type to map to
      Returns:
      a mapper for the given type, or empty if no row or column mapper is registered for the given type.
    • findFor

      public Optional<RowMapper<?>> findFor(Type type)
      Obtain a mapper for the given type. If a row mapper is registered for the given type, it is returned. If a column mapper is registered for the given type, it is adapted into a row mapper, mapping the first column of the result set. If neither a row or column mapper is registered, empty is returned.
      Parameters:
      type - the target type to map to
      Returns:
      a mapper for the given type, or empty if no row or column mapper is registered for the given type.
    • findFor

      public <T> Optional<RowMapper<T>> findFor(QualifiedType<T> type)
      Obtain a mapper for the given qualified type. If the type is unqualified, and a row mapper is registered for the given type, it is returned. If a column mapper is registered for the given qualified type, it is adapted into a row mapper, mapping the first column of the result set. If neither a row or column mapper is registered, empty is returned.
      Parameters:
      type - the target qualified type to map to
      Returns:
      a mapper for the given type, or empty if no row or column mapper is registered for the given type.
    • createCopy

      public Mappers createCopy()
      Description copied from interface: JdbiConfig
      Returns a copy of this configuration object. Changes to the copy should not modify the original, and vice-versa.
      Specified by:
      createCopy in interface JdbiConfig<Mappers>
      Returns:
      a copy of this configuration object.