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