Package org.jdbi.v3.core.mapper
Class Mappers
- java.lang.Object
-
- org.jdbi.v3.core.mapper.Mappers
-
- All Implemented Interfaces:
JdbiConfig<Mappers>
public class Mappers extends java.lang.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
RowMappersorColumnMappers.
-
-
Field Summary
Fields Modifier and Type Field Description private ColumnMapperscolumnMappersprivate RowMappersrowMappers
-
Constructor Summary
Constructors Constructor Description Mappers()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MapperscreateCopy()Returns a copy of this configuration object.<T> java.util.Optional<RowMapper<T>>findFor(java.lang.Class<T> type)Obtain a mapper for the given type.java.util.Optional<RowMapper<?>>findFor(java.lang.reflect.Type type)Obtain a mapper for the given type.<T> java.util.Optional<RowMapper<T>>findFor(GenericType<T> type)Obtain a mapper for the given type.<T> java.util.Optional<RowMapper<T>>findFor(QualifiedType<T> type)Obtain a mapper for the given qualified type.voidsetRegistry(ConfigRegistry registry)The registry will inject itself into the configuration object.
-
-
-
Field Detail
-
rowMappers
private RowMappers rowMappers
-
columnMappers
private ColumnMappers columnMappers
-
-
Method Detail
-
setRegistry
public void setRegistry(ConfigRegistry registry)
Description copied from interface:JdbiConfigThe 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:
setRegistryin interfaceJdbiConfig<Mappers>- Parameters:
registry- the registry that owns this configuration object
-
findFor
public <T> java.util.Optional<RowMapper<T>> findFor(java.lang.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> java.util.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 java.util.Optional<RowMapper<?>> findFor(java.lang.reflect.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> java.util.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:JdbiConfigReturns a copy of this configuration object. Changes to the copy should not modify the original, and vice-versa.- Specified by:
createCopyin interfaceJdbiConfig<Mappers>- Returns:
- a copy of this configuration object.
-
-