All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sfm.jdbc.impl.JdbcMapperImpl Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

There is a newer version: 1.10.3
Show newest version
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
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy