Package org.jdbi.v3.core.mapper
Class GenericMapMapperFactory
- java.lang.Object
-
- org.jdbi.v3.core.mapper.GenericMapMapperFactory
-
- All Implemented Interfaces:
RowMapperFactory
@Beta public class GenericMapMapperFactory extends java.lang.Object implements RowMapperFactory
Factory for a RowMapper that can map resultset rows to column name/generic valueMaps. Each row in the resultset becomes a distinctMap, in which the keys are all distinct column names and the values are the corresponding cell contents. All values are mapped to the same generic typeT(e.g.BigDecimal) by aColumnMapperfrom theConfigRegistry. This differs fromMapMapperby supporting a concrete type instead of onlyObject, and fromcollectinginto aMapin that the latter maps an entire resultset to a singleMapand can only keep 1 key and 1 value from each row. Use cases for this are mainly single-row results like numeric reports (e.g. the price components, taxes, etc of a product for sale, or a set of possible labeled values for a user setting), and matrices.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classGenericMapMapperFactory.GenericMapMapper<T>
-
Constructor Summary
Constructors Constructor Description GenericMapMapperFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<RowMapper<?>>build(java.lang.reflect.Type mapType, ConfigRegistry config)Supplies a row mapper which will map result set rows to type if the factory supports it; empty otherwise.static <T> RowMapper<java.util.Map<java.lang.String,T>>getMapperForValueType(java.lang.Class<T> valueType, ConfigRegistry config)static <T> RowMapper<java.util.Map<java.lang.String,T>>getMapperForValueType(GenericType<T> valueType, ConfigRegistry config)
-
-
-
Method Detail
-
build
public java.util.Optional<RowMapper<?>> build(java.lang.reflect.Type mapType, ConfigRegistry config)
Description copied from interface:RowMapperFactorySupplies a row mapper which will map result set rows to type if the factory supports it; empty otherwise.- Specified by:
buildin interfaceRowMapperFactory- Parameters:
mapType- the target type to map toconfig- the config registry, for composition- Returns:
- a row mapper for the given type if this factory supports it;
Optional.empty()otherwise. - See Also:
for composition
-
getMapperForValueType
@Beta public static <T> RowMapper<java.util.Map<java.lang.String,T>> getMapperForValueType(java.lang.Class<T> valueType, ConfigRegistry config)
-
getMapperForValueType
@Beta public static <T> RowMapper<java.util.Map<java.lang.String,T>> getMapperForValueType(GenericType<T> valueType, ConfigRegistry config)
-
-