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 LongColumnMapper implements ResultColumnMapper<Long> {
PRIMITIVE(false),
WRAPPER(true);
private final boolean nullable;
LongColumnMapper(boolean nullable) {
this.nullable = nullable;
}
@Override
public Long mapColumn(ResultSet r, int columnNumber, StatementContext ctx) throws SQLException {
long value = r.getLong(columnNumber);
return nullable && r.wasNull() ? null : value;
}
@Override
public Long mapColumn(ResultSet r, String columnLabel, StatementContext ctx) throws SQLException {
long value = r.getLong(columnLabel);
return nullable && r.wasNull() ? null : value;
}
}