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

org.simpleflatmapper.jdbc.impl.getter.IntResultSetGetter Maven / Gradle / Ivy

package org.simpleflatmapper.jdbc.impl.getter;

import org.simpleflatmapper.converter.Context;
import org.simpleflatmapper.map.getter.ContextualGetter;
import org.simpleflatmapper.map.getter.IntContextualGetter;
import org.simpleflatmapper.reflect.Getter;
import org.simpleflatmapper.reflect.primitive.IntGetter;

import java.sql.ResultSet;
import java.sql.SQLException;

public final class IntResultSetGetter implements
		IntGetter, Getter,
		IntContextualGetter, ContextualGetter
{

	private final int column;
	
	public IntResultSetGetter(final int column) {
		this.column = column;
	}

	@Override
	public int getInt(final ResultSet target) throws SQLException {
		return target.getInt(column);
	}

	@Override
	public Integer get(ResultSet resultSet, Context context) throws Exception {
		return get(resultSet);
	}

	@Override
	public int getInt(ResultSet resultSet, Context mappingContext) throws Exception {
		return getInt(resultSet);
	}

	@Override
	public Integer get(final ResultSet target) throws Exception {
		final int i = getInt(target);
		if (i == 0 && target.wasNull()) {
			return null;
		} else {
			return i;
		}
	}

    @Override
    public String toString() {
        return "IntResultSetGetter{" +
                "property=" + column +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy