class HbaseSchemaUtils {

    public static Object coerceType(boolean isNative, ArrowType type, byte[] value)
    {
        if (value == null) {
            return null;
        }

        Types.MinorType minorType = Types.getMinorTypeForArrowType(type);
        switch (minorType) {
            case VARCHAR:
                return Bytes.toString(value);
            case INT:
                return isNative ? ByteBuffer.wrap(value).getInt() : Integer.parseInt(Bytes.toString(value));
            case BIGINT:
                return isNative ? ByteBuffer.wrap(value).getLong() : Long.parseLong(Bytes.toString(value));
            case FLOAT4:
                return isNative ? ByteBuffer.wrap(value).getFloat() : Float.parseFloat(Bytes.toString(value));
            case FLOAT8:
                return isNative ? ByteBuffer.wrap(value).getDouble() : Double.parseDouble(Bytes.toString(value));
            case BIT:
                if (isNative) {
                    return (value[0] != 0);
                }
                else {
                    return Boolean.parseBoolean(Bytes.toString(value));
                }
            case VARBINARY:
                return value;
            default:
                throw new IllegalArgumentException(type + " with minorType[" + minorType + "] is not supported.");
        }
    }

    private  HbaseSchemaUtils();

}