public static ClickHouseByteBuffer of(ByteBuffer buffer) {
        if (buffer == null || !buffer.hasRemaining()) {
            return newInstance();
        }

        int pos = buffer.position();
        int len = buffer.remaining();
        byte[] bytes;
        if (buffer.hasArray()) {
            bytes = buffer.array();
        } else {
            bytes = new byte[len];
            buffer.get(bytes);
            ((Buffer) buffer).position(pos);
            pos = 0;
        }
        return new ClickHouseByteBuffer(bytes, pos, len);
    }
Wraps given byte buffer.

@param buffer byte buffer
@return non-null wrapped byte buffer
clickhouse-data/src/main/java/com/clickhouse/data/ClickHouseByteBuffer.java