code: public ByteBuffer toThrift() {
      Buffer buffer = Buffer.allocate(sizeInBytes());
      write(buffer);
      return ByteBuffer.wrap(buffer.toByteArray());
    }
docs: Writes the current instance in TBinaryProtocol