Top Description Fields Constructors Methods
org.springframework.r2dbc.core

public Class ColumnMapRowMapper

extends Object
implements BiFunction<Row, RowMetadata, Map<String, Object>>
Class Inheritance
All Implemented Interfaces
java.util.function.BiFunction
Imports
java.util.List, .Map, java.util.function.BiFunction, io.r2dbc.spi.ColumnMetadata, .Row, .RowMetadata, org.springframework.lang.Nullable, org.springframework.util.LinkedCaseInsensitiveMap

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 and getColumnKey, 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.

Author
Mark Paluch
Since
5.3

Field Summary

Modifier and TypeField and Description
public static final ColumnMapRowMapper
INSTANCE

A default ColumnMapRowMapper instance.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Map<String, Object>
apply(Row
the first function argument
row
,
RowMetadata
the second function argument
rowMetadata
)

Implements java.util.function.BiFunction.apply.

Applies this function to the given arguments.

protected Map<String, Object>

Returns:

the new Map instance
createColumnMap
(int
the column count, to be used as initial capacity for the Map
columnCount
)

Create a Map instance to be used as column map.

protected String

Returns:

the column key to use
getColumnKey
(String
the column name as returned by the Row
columnName
)

Determine the key to use for the given column in the column Map.

protected Object

Returns:

the Object returned
getColumnValue
(Row
is the Row holding the data
row
,
int
is the column index
index
)

Retrieve a R2DBC object value for the specified column.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
public static final ColumnMapRowMapper INSTANCE

A default ColumnMapRowMapper instance.

Constructor Detail

ColumnMapRowMapperback to summary
public ColumnMapRowMapper()

Method Detail

applyback to summary
public Map<String, Object> apply(Row row, RowMetadata rowMetadata)

Implements java.util.function.BiFunction.apply.

Doc from java.util.function.BiFunction.apply.

Applies this function to the given arguments.

Parameters
row:Row

the first function argument

rowMetadata:RowMetadata

the second function argument

Returns:Map<String, Object>

the function result

Annotations
@SuppressWarnings:deprecation
@Override
createColumnMapback to summary
protected Map<String, Object> createColumnMap(int columnCount)

Create a Map instance to be used as column map.

By default, a linked case-insensitive Map will be created.

Parameters
columnCount:int

the column count, to be used as initial capacity for the Map

Returns:Map<String, Object>

the new Map instance

See Also
LinkedCaseInsensitiveMap
getColumnKeyback to summary
protected String getColumnKey(String columnName)

Determine the key to use for the given column in the column Map.

Parameters
columnName:String

the column name as returned by the Row

Returns:String

the column key to use

See Also
ColumnMetadata#getName()
getColumnValueback to summary
protected Object getColumnValue(Row row, int index)

Retrieve a R2DBC object value for the specified column.

The default implementation uses the Row#get(int) method.

Parameters
row:Row

is the Row holding the data

index:int

is the column index

Returns:Object

the Object returned

Annotations
@Nullable