use of org.simpleflatmapper.jdbc.impl.ResultSetEnumarable in project SimpleFlatMapper by arnaudroger.
the class DiscriminatorJdbcBuilder method mapper.
/**
* @return a new jdbcMapper based on the current state
*/
public JdbcMapper<T> mapper() {
List<DiscriminatorMapper.PredicatedMapper<ResultSet, ResultSet, T, SQLException>> mappers = new ArrayList<DiscriminatorMapper.PredicatedMapper<ResultSet, ResultSet, T, SQLException>>();
for (DiscriminatorJdbcSubBuilder subBuilder : builders) {
JdbcMapper<T> mapper = subBuilder.createMapper();
Predicate<ResultSet> predicate = new ResultSetDiscriminatorPredicate(column, subBuilder.predicate);
mappers.add(new DiscriminatorMapper.PredicatedMapper<ResultSet, ResultSet, T, SQLException>(predicate, mapper, mapper));
}
DiscriminatorJdbcMapper<T> discriminatorMapper = new DiscriminatorJdbcMapper<T>(mappers, new UnaryFactory<ResultSet, Enumarable<ResultSet>>() {
@Override
public Enumarable<ResultSet> newInstance(ResultSet resultSet) {
return new ResultSetEnumarable(resultSet);
}
}, UncheckedConverterHelper.<ResultSet, String>toUnchecked(new Converter<ResultSet, String>() {
@Override
public String convert(ResultSet in) throws SQLException {
return column + ":" + in.getObject(column);
}
}), jdbcMapperFactory.consumerErrorHandler());
return discriminatorMapper;
}
Aggregations