use of org.jdbi.v3.sqlobject.statement.UseRowReducer in project jdbi by jdbi.
the class SqlQueryHandler method configureReturner.
@Override
void configureReturner(Query q, SqlObjectStatementConfiguration cfg) {
UseRowMapper useRowMapper = getMethod().getAnnotation(UseRowMapper.class);
UseRowReducer useRowReducer = getMethod().getAnnotation(UseRowReducer.class);
if (useRowReducer != null && useRowMapper != null) {
throw new IllegalStateException("Cannot declare @UseRowMapper and @UseRowReducer on the same method.");
}
cfg.setReturner(() -> {
StatementContext ctx = q.getContext();
Type elementType = magic.elementType(ctx);
if (useRowReducer != null) {
return magic.reducedResult(q.reduceRows(rowReducerFor(useRowReducer)), ctx);
}
ResultIterable<?> iterable = useRowMapper == null ? q.mapTo(elementType) : q.map(rowMapperFor(useRowMapper));
return magic.mappedResult(iterable, ctx);
});
}
Aggregations