Class RowMappers
- All Implemented Interfaces:
JdbiConfig<RowMappers>
RowMapperFactory instances.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a copy of this configuration object.Obtain a row mapper for the given type in the given context.Obtain a row mapper for the given type in the given context.Obtain a row mapper for the given type that declares the given column name prefix.findFor(GenericType<T> type) Obtain a row mapper for the given type in the given context.Returns theJdbiInterceptionChainHolderfor the RowMapper inference.Register a row mapper for a given type.<T> RowMappersregister(GenericType<T> type, RowMapper<T> mapper) Register a row mapper for a given type.Register a row mapper which will have its parameterized type inspected to determine what it maps to.register(RowMapperFactory factory) Register a row mapper factory.voidsetRegistry(ConfigRegistry registry) The registry will inject itself into the configuration object.
-
Constructor Details
-
RowMappers
public RowMappers()
-
-
Method Details
-
setRegistry
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<RowMappers>- Parameters:
registry- the registry that owns this configuration object
-
getInferenceInterceptors
@Alpha public JdbiInterceptionChainHolder<RowMapper<?>, RowMapperFactory> getInferenceInterceptors()Returns theJdbiInterceptionChainHolderfor the RowMapper inference. This chain allows registration of custom interceptors to change the standard type inference for theregister(RowMapper)method. -
register
Register a row mapper which will have its parameterized type inspected to determine what it maps to. Will be used withResultBearing.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.
Objectis 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
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
Register a row mapper for a given type.- Parameters:
type- the type to match with equals.mapper- the row mapper- Returns:
- this
-
register
Register a row mapper factory.Will be used with
ResultBearing.mapTo(Class)for registered mappings.- Parameters:
factory- the row mapper factory- Returns:
- this
-
findFor
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
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
-
findFor
Obtain a row mapper for the given type that declares the given column name prefix.Only mappers that implement
PrefixedRowMappertake part in this lookup, and a mapper matches only if itsdeclared prefixis equal to the given prefix. The comparison is an exact, case-sensitive string comparison. Mappers that do not declare a prefix never match, no matter what type they map.The reflective mappers (
BeanMapper,ConstructorMapper,FieldMapper) declare the prefix given at registration, or the empty string when registered without one.Use this lookup to tell apart multiple mappers for the same type that read differently prefixed column sets, for example when a query joins the same table twice. To look up a mapper by type alone, use
findFor(Type).- Parameters:
type- the target type to map toprefix- the column name prefix the mapper must declare, never null- Returns:
- a RowMapper for the given type and prefix, or empty if no matching row mapper is registered.
-
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<RowMappers>- Returns:
- a copy of this configuration object.
-