package org.skife.jdbi.v2.util;
import org.skife.jdbi.v2.StatementContext;
import org.skife.jdbi.v2.tweak.ResultColumnMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
public enum DoubleColumnMapper implements ResultColumnMapper<Double> {
PRIMITIVE(false),
WRAPPER(true);
private final boolean nullable;
DoubleColumnMapper(boolean nullable) {
this.nullable = nullable;
}
@Override
public Double mapColumn(ResultSet r, int columnNumber, StatementContext ctx) throws SQLException {
double value = r.getDouble(columnNumber);
return nullable && r.wasNull() ? null : value;
}
@Override
public Double mapColumn(ResultSet r, String columnLabel, StatementContext ctx) throws SQLException {
double value = r.getDouble(columnLabel);
return nullable && r.wasNull() ? null : value;
}
}