BinaryType implements Binary { @Override public int hashCode() { int hash = 1; for (byte b : this.data) { hash = 31 * hash + b; } return hash; } BinaryType(byte[] data);  BinaryType(String base64); @Override byte[] getData(); @Override void getData(byte[] buffer, int offset); @Override int getLength(); @Override String getHex(); @Override String getBase64(); @Override boolean isZeros(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static byte[] parseHex(String hex); static String formatHex(byte[] data); static byte[] parseBase64(String base64); static String formatBase64(byte[] data); static byte[] toBytes(long value); static byte[] toBytes(int value); static long toLong(byte[] data); static long toInt(byte[] data);  }
@Test public void testEqualsAndHashCode() { BinaryType byteBlob = new Blob(SAMPLE_BLOB_DATA); BinaryType base64Blob = new Blob(SAMPLE_BLOB_BASE64); assertThat(byteBlob).isEqualTo(base64Blob).isEqualTo(byteBlob); assertThat(byteBlob.hashCode()).isEqualTo(base64Blob.hashCode()); assertThat(byteBlob).isNotEqualTo(null).isNotEqualTo("").isNotEqualTo(new Blob("12345678")); }