use of org.jdbi.v3.core.mapper.Mappers in project jdbi by jdbi.
the class JoinRowMapper method specialize.
@Override
public RowMapper<JoinRow> specialize(ResultSet r, StatementContext ctx) throws SQLException {
RowMapper<?>[] mappers = new RowMapper[types.length];
for (int i = 0; i < types.length; i++) {
Type type = types[i];
mappers[i] = ctx.findRowMapperFor(type).orElseThrow(() -> new IllegalArgumentException("No row mapper registered for " + type)).specialize(r, ctx);
}
return (rs, context) -> {
final Map<Type, Object> entries = new HashMap<>(types.length);
for (int i = 0; i < types.length; i++) {
Type type = types[i];
RowMapper<?> mapper = mappers[i];
entries.put(type, mapper.map(r, ctx));
}
return new JoinRow(entries);
};
}
Aggregations