org.sfm.jdbc.impl.JdbcMapperImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simpleFlatMapper Show documentation
Show all versions of simpleFlatMapper Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
package org.sfm.jdbc.impl;
import org.sfm.jdbc.JdbcMapper;
import org.sfm.map.*;
import org.sfm.map.impl.MapperImpl;
import org.sfm.reflect.Instantiator;
import org.sfm.utils.RowHandler;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Iterator;
//IFJAVA8_START
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
//IFJAVA8_END
public final class JdbcMapperImpl extends MapperImpl implements JdbcMapper {
private final RowHandlerErrorHandler errorHandler;
public JdbcMapperImpl(final FieldMapper[] fieldMappers,
final FieldMapper[] constructorMappers,
final Instantiator instantiator,
final RowHandlerErrorHandler errorHandler,
final MappingContextFactory mappingContextFactory) {
super(fieldMappers, constructorMappers, instantiator, mappingContextFactory);
this.errorHandler = errorHandler;
}
@Override
public final > H forEach(final ResultSet rs, final H handler)
throws SQLException, MappingException {
return JdbcMapperHelper.forEach(rs, handler, newMappingContext(rs), this, errorHandler);
}
@Override
@Deprecated
public Iterator iterate(ResultSet rs) throws SQLException,
MappingException {
return new ResultSetIterator(rs, this, newMappingContext(rs));
}
@Override
@SuppressWarnings("deprecation")
public Iterator iterator(ResultSet rs) throws SQLException,
MappingException {
return iterate(rs);
}
//IFJAVA8_START
@Override
public Stream stream(ResultSet rs) throws SQLException, MappingException {
return StreamSupport.stream(new ResultSetSpliterator(rs, this, newMappingContext(rs)), false);
}
//IFJAVA8_END
}