package sharin.sql.runner.converter;

import java.sql.ResultSet;

import sharin.sql.runner.ColumnConverter;
import sharin.util.SqlUtils;

public class IntegerColumnConverter implements ColumnConverter {

    public Object convert(ResultSet rs, int columnIndex) {
        int value = SqlUtils.getInt(rs, columnIndex);

        if (value == 0 && SqlUtils.wasNull(rs)) {
            return null;
        }

        return value;
    }
}
