ByteKey implements Comparable<ByteKey>, Serializable { @Override public String toString() { char[] encoded = new char[2 * value.size() + 2]; encoded[0] = '['; int cnt = 1; ByteIterator iterator = value.iterator(); while (iterator.hasNext()) { byte b = iterator.nextByte(); encoded[cnt] = HEX[(b & 0xF0) >>> 4]; ++cnt; encoded[cnt] = HEX[b & 0xF]; ++cnt; } encoded[cnt] = ']'; return new String(encoded); } private  ByteKey(ByteString value); static ByteKey copyFrom(ByteBuffer value); static ByteKey copyFrom(byte[] bytes); static ByteKey of(int... bytes); ByteBuffer getValue(); byte[] getBytes(); boolean isEmpty(); @Override int compareTo(@Nonnull ByteKey other); @Override String toString(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); static final ByteKey EMPTY; }
@Test public void testToString() { assertEquals("[]", ByteKey.EMPTY.toString()); assertEquals("[00]", ByteKey.of(0).toString()); assertEquals("[0000]", ByteKey.of(0x00, 0x00).toString()); assertEquals( "[0123456789abcdef]", ByteKey.of(0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef).toString()); }