public class ColumnMapRowMapper extends Object implements BiFunction<io.r2dbc.spi.Row,io.r2dbc.spi.RowMetadata,Map<String,Object>>
Mapping function implementation that creates a
java.util.Map for each row, representing all columns as
key-value pairs: one entry for each column, with the column name as key.
The Map implementation to use and the key to use for each column
in the column Map can be customized through overriding
createColumnMap(int) and getColumnKey(java.lang.String), respectively.
Note: By default, ColumnMapRowMapper will try to build a linked Map with case-insensitive keys, to preserve column order as well as allow any casing to be used for column names. This requires Commons Collections on the classpath (which will be autodetected). Else, the fallback is a standard linked HashMap, which will still preserve column order but requires the application to specify the column names in the same casing as exposed by the driver.
| Modifier and Type | Field and Description |
|---|---|
static ColumnMapRowMapper |
INSTANCE
A default
ColumnMapRowMapper instance. |
| Constructor and Description |
|---|
ColumnMapRowMapper() |
| Modifier and Type | Method and Description |
|---|---|
Map<String,Object> |
apply(io.r2dbc.spi.Row row,
io.r2dbc.spi.RowMetadata rowMetadata) |
protected Map<String,Object> |
createColumnMap(int columnCount)
Create a
Map instance to be used as column map. |
protected String |
getColumnKey(String columnName)
Determine the key to use for the given column in the column
Map. |
protected Object |
getColumnValue(io.r2dbc.spi.Row row,
int index)
Retrieve a R2DBC object value for the specified column.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitandThenpublic static final ColumnMapRowMapper INSTANCE
ColumnMapRowMapper instance.public Map<String,Object> apply(io.r2dbc.spi.Row row, io.r2dbc.spi.RowMetadata rowMetadata)
apply in interface BiFunction<io.r2dbc.spi.Row,io.r2dbc.spi.RowMetadata,Map<String,Object>>protected Map<String,Object> createColumnMap(int columnCount)
Map instance to be used as column map.
By default, a linked case-insensitive Map will be created.
columnCount - the column count, to be used as initial capacity for the MapMap instanceLinkedCaseInsensitiveMapprotected String getColumnKey(String columnName)
Map.columnName - the column name as returned by the RowColumnMetadata.getName()@Nullable protected Object getColumnValue(io.r2dbc.spi.Row row, int index)
The default implementation uses the Row.get(int) method.
row - is the Row holding the dataindex - is the column index