@Beta public class GenericMapMapperFactory extends Object implements RowMapperFactory
Maps.
Each row in the resultset becomes a distinct Map, 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 type T (e.g. BigDecimal) by a ColumnMapper from the ConfigRegistry.
This differs from MapMapper by supporting a concrete type instead of only Object, and from collecting into a Map
in that the latter maps an entire resultset to a single Map and 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.| Constructor and Description |
|---|
GenericMapMapperFactory() |
| Modifier and Type | Method and Description |
|---|---|
Optional<RowMapper<?>> |
build(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<Map<String,T>> |
getMapperForValueType(Class<T> valueType,
ConfigRegistry config) |
static <T> RowMapper<Map<String,T>> |
getMapperForValueType(GenericType<T> valueType,
ConfigRegistry config) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitofpublic Optional<RowMapper<?>> build(Type mapType, ConfigRegistry config)
RowMapperFactorybuild in interface RowMapperFactorymapType - the target type to map toconfig - the config registry, for compositionOptional.empty() otherwise.for composition@Beta public static <T> RowMapper<Map<String,T>> getMapperForValueType(Class<T> valueType, ConfigRegistry config)
@Beta public static <T> RowMapper<Map<String,T>> getMapperForValueType(GenericType<T> valueType, ConfigRegistry config)
Copyright © 2019. All rights reserved.