Class RowMappers

    • Constructor Detail

      • RowMappers

        public RowMappers()
      • RowMappers

        private RowMappers​(RowMappers that)
    • Method Detail

      • 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
      • 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:
        java.lang.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​(java.lang.reflect.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
      • findFor

        public <T> java.util.Optional<RowMapper<T>> findFor​(java.lang.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> java.util.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 java.util.Optional<RowMapper<?>> findFor​(java.lang.reflect.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.