Package org.jdbi.v3.core.mapper
Class RowMappers
- java.lang.Object
-
- org.jdbi.v3.core.mapper.RowMappers
-
- All Implemented Interfaces:
JdbiConfig<RowMappers>
public class RowMappers extends java.lang.Object implements JdbiConfig<RowMappers>
Configuration registry forRowMapperFactoryinstances.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.reflect.Type,java.util.Optional<RowMapper<?>>>cacheprivate java.util.List<RowMapperFactory>factoriesprivate JdbiInterceptionChainHolder<RowMapper<?>,RowMapperFactory>inferenceInterceptorsprivate ConfigRegistryregistry
-
Constructor Summary
Constructors Modifier Constructor Description RowMappers()privateRowMappers(RowMappers that)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RowMapperscreateCopy()Returns a copy of this configuration object.<T> java.util.Optional<RowMapper<T>>findFor(java.lang.Class<T> type)Obtain a row mapper for the given type in the given context.java.util.Optional<RowMapper<?>>findFor(java.lang.reflect.Type type)Obtain a row mapper for the given type in the given context.<T> java.util.Optional<RowMapper<T>>findFor(GenericType<T> type)Obtain a row mapper for the given type in the given context.JdbiInterceptionChainHolder<RowMapper<?>,RowMapperFactory>getInferenceInterceptors()Returns theJdbiInterceptionChainHolderfor the RowMapper inference.RowMappersregister(java.lang.reflect.Type type, RowMapper<?> mapper)Register a row mapper for a given type.<T> RowMappersregister(GenericType<T> type, RowMapper<T> mapper)Register a row mapper for a given type.RowMappersregister(RowMapper<?> mapper)Register a row mapper which will have its parameterized type inspected to determine what it maps to.RowMappersregister(RowMapperFactory factory)Register a row mapper factory.voidsetRegistry(ConfigRegistry registry)The registry will inject itself into the configuration object.
-
-
-
Field Detail
-
inferenceInterceptors
private final JdbiInterceptionChainHolder<RowMapper<?>,RowMapperFactory> inferenceInterceptors
-
factories
private final java.util.List<RowMapperFactory> factories
-
cache
private final java.util.Map<java.lang.reflect.Type,java.util.Optional<RowMapper<?>>> cache
-
registry
private ConfigRegistry registry
-
-
Constructor Detail
-
RowMappers
public RowMappers()
-
RowMappers
private RowMappers(RowMappers that)
-
-
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<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
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 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:
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
-
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> 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: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.
-
-