-
- All Superinterfaces:
Function<R,E>
- All Known Implementing Classes:
DefaultRecordMapper
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface RecordMapper<R extends Record,E> extends Function<R,E>
ARecordMapper
is a mapper that can receiveRecord
objects, when fetching data from the database, transforming them into a custom type<E>
.RecordMapper
is used behind the scenes in methods likeResultQuery.fetchInto(Class)
,Result.into(Class)
,Record.into(Class)
and other methods calledinto(Class)
, where the argument class is aClass
of typeE
.The default
RecordMapper
behaviour in the context of aConfiguration
can be overridden through thatconfiguration
'sConfiguration.recordMapperProvider()
SPI. Custom record mappers can be constructed using lambda expressions, using variousRecords.mapping(Function1)
,Records.mapping(Function2)
, etc. utilities, and other ways.A
RecordMapper
is never asked to mapnull
record values, which can be obtained using methods likeResultQuery.fetchOne(RecordMapper)
, or by usingRowN
types as nested records in scalar subqueries, mapping them e.g. viaRow2.mapping(Function2)
. Instead,null
is produced without passing by this SPI.The inverse operation is modelled by
RecordUnmapper
.- Author:
- Lukas Eder
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default E
apply(R record)
E
map(R record)
Map a record into a POJO.
-