Class RowMappers

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

public class RowMappers extends Object implements JdbiConfig<RowMappers>
Configuration registry for RowMapperFactory instances.
  • Constructor Details

    • RowMappers

      public RowMappers()
  • 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<RowMappers>
      Parameters:
      registry - the registry that owns this configuration object
    • getInferenceInterceptors

      @Alpha public JdbiInterceptionChainHolder<RowMapper<?>,RowMapperFactory> getInferenceInterceptors()
      Returns the JdbiInterceptionChainHolder for the RowMapper inference. This chain allows registration of custom interceptors to change the standard type inference for the register(RowMapper) method.
    • register

      public RowMappers register(RowMapper<?> mapper)
      Register a row mapper which will have its parameterized type inspected to determine what it maps to. Will be used with ResultBearing.mapTo(Class) for registered mappings.

      The parameter must be concretely parameterized, we use the type argument T to determine if it applies to a given type.

      Object is not supported as a concrete parameter type.

      Parameters:
      mapper - the row mapper
      Returns:
      this
      Throws:
      UnsupportedOperationException - if the RowMapper is not a concretely parameterized type
    • register

      public <T> RowMappers register(GenericType<T> type, RowMapper<T> mapper)
      Register a row mapper for a given type.
      Type Parameters:
      T - the type
      Parameters:
      type - the type to match with equals.
      mapper - the row mapper
      Returns:
      this
    • register

      public RowMappers register(Type type, RowMapper<?> mapper)
      Register a row mapper for a given type.
      Parameters:
      type - the type to match with equals.
      mapper - the row mapper
      Returns:
      this
    • register

      public RowMappers register(RowMapperFactory factory)
      Register a row mapper factory.

      Will be used with ResultBearing.mapTo(Class) for registered mappings.

      Parameters:
      factory - the row mapper factory
      Returns:
      this
    • findFor

      public <T> Optional<RowMapper<T>> findFor(Class<T> type)
      Obtain a row mapper for the given type in the given context.
      Type Parameters:
      T - the type of the mapper to find
      Parameters:
      type - the target type to map to
      Returns:
      a RowMapper for the given type, or empty if no row mapper is registered for the given type.
    • findFor

      public <T> Optional<RowMapper<T>> findFor(GenericType<T> type)
      Obtain a row mapper for the given type in the given context.
      Type Parameters:
      T - the type of the mapper to find
      Parameters:
      type - the target type to map to
      Returns:
      a RowMapper for the given type, or empty if no row mapper is registered for the given type.
    • findFor

      public Optional<RowMapper<?>> findFor(Type type)
      Obtain a row mapper for the given type in the given context.
      Parameters:
      type - the target type to map to
      Returns:
      a RowMapper for the given type, or empty if no row mapper is registered for the given type.
    • createCopy

      public RowMappers 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<RowMappers>
      Returns:
      a copy of this configuration object.