@Override public String toString() {
    if (size == 0) {
      return "Buffer[size=0]";
    }

    if (size <= 16) {
      ByteString data = clone().readByteString();
      return String.format("Buffer[size=%s data=%s]", size, data.hex());
    }

    MessageDigest md5 = new MessageDigest("MD5");
    md5.update(head.data, head.pos, head.limit - head.pos);
    for (Segment s = head.next; s != head; s = s.next) {
      md5.update(s.data, s.pos, s.limit - s.pos);
    }
    return String.format("Buffer[size=%s md5=%s]",
          size, ByteString.of(md5.digest()).hex());
  }
@Test public void toStringOnEmptyBuffer() throws Exception {
    Buffer buffer = new Buffer();
    assertEquals("Buffer[size=0]", buffer.toString());
  }