Package org.jdbi.v3.core.mapper
Class MapEntryMapper<K,V>
- java.lang.Object
-
- org.jdbi.v3.core.mapper.MapEntryMapper<K,V>
-
- Type Parameters:
K- entry key typeV- entry value type
- All Implemented Interfaces:
RowMapper<java.util.Map.Entry<K,V>>
public class MapEntryMapper<K,V> extends java.lang.Object implements RowMapper<java.util.Map.Entry<K,V>>
Maps rows toMap.Entry<K, V>, provided there are mappers registered for types K and V. This mapper is registered out of the box.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.reflect.TypeVariable<java.lang.Class<java.util.Map.Entry>>KEY_PARAMprivate RowMapper<K>keyMapperprivate static java.lang.reflect.TypeVariable<java.lang.Class<java.util.Map.Entry>>VALUE_PARAMprivate RowMapper<V>valueMapper
-
Constructor Summary
Constructors Modifier Constructor Description privateMapEntryMapper(RowMapper<K> keyMapper, RowMapper<V> valueMapper)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static RowMapperFactoryfactory()private static RowMapper<?>getKeyMapper(java.lang.reflect.Type keyType, ConfigRegistry config)private static RowMapper<?>getValueMapper(java.lang.reflect.Type valueType, ConfigRegistry config)java.util.Map.Entry<K,V>map(java.sql.ResultSet rs, StatementContext ctx)Map the current row of the result set.RowMapper<java.util.Map.Entry<K,V>>specialize(java.sql.ResultSet rs, StatementContext ctx)Returns a specialized row mapper, optimized for the given result set.
-
-
-
Method Detail
-
factory
static RowMapperFactory factory()
-
getKeyMapper
private static RowMapper<?> getKeyMapper(java.lang.reflect.Type keyType, ConfigRegistry config)
-
getValueMapper
private static RowMapper<?> getValueMapper(java.lang.reflect.Type valueType, ConfigRegistry config)
-
map
public java.util.Map.Entry<K,V> map(java.sql.ResultSet rs, StatementContext ctx) throws java.sql.SQLException
Description copied from interface:RowMapperMap the current row of the result set. This method should not cause the result set to advance; allow Jdbi to do that, please.
-
specialize
public RowMapper<java.util.Map.Entry<K,V>> specialize(java.sql.ResultSet rs, StatementContext ctx) throws java.sql.SQLException
Description copied from interface:RowMapperReturns a specialized row mapper, optimized for the given result set.Before mapping the result set from a SQL statement; Jdbi will first call this method to obtain a specialized instance. The returned mapper will then be used to map the result set rows, and discarded.
Implementing this method is optional; the default implementation returns
this. Implementors might choose to override this method to improve performance, e.g. by matching up column names to properties once for the entire result set, rather than repeating the process for every row.- Specified by:
specializein interfaceRowMapper<K>- Parameters:
rs- the result set to specialize overctx- the statement context to specialize over- Returns:
- a row mapper equivalent to this one, possibly specialized.
- Throws:
java.sql.SQLException- if anything goes wrong go ahead and let this percolate; Jdbi will handle it- See Also:
for an example of specialization.
-
-