BlobKey implements Serializable, Comparable<BlobKey> { @Override public int compareTo(BlobKey o) { final byte[] aarr = this.key; final byte[] barr = o.key; final int len = Math.min(aarr.length, barr.length); for (int i = 0; i < len; ++i) { final int a = (aarr[i] & 0xff); final int b = (barr[i] & 0xff); if (a != b) { return a - b; } } return aarr.length - barr.length; } BlobKey();   BlobKey(byte[] key); void addToMessageDigest(MessageDigest md); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); @Override int compareTo(BlobKey o);  }
@Test public void testCompares() { final BlobKey k1 = new BlobKey(KEY_ARRAY_1); final BlobKey k2 = new BlobKey(KEY_ARRAY_1); final BlobKey k3 = new BlobKey(KEY_ARRAY_2); assertTrue(k1.compareTo(k2) == 0); assertTrue(k1.compareTo(k3) < 0); }