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

org.sfm.jdbc.impl.AbstractJdbcMapperImpl 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.MappingContextFactory;
import org.sfm.map.MappingException;
import org.sfm.map.RowHandlerErrorHandler;
import org.sfm.map.impl.AbstractMapperImpl;
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 abstract class AbstractJdbcMapperImpl extends AbstractMapperImpl implements JdbcMapper {
	
	private final RowHandlerErrorHandler errorHandler; 
	
	public AbstractJdbcMapperImpl(final Instantiator instantiator,
                                  final RowHandlerErrorHandler errorHandler,
                                  final MappingContextFactory mappingContextFactory) {
		super(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