BinaryType implements Binary { public static long toLong(byte[] data) { assert (data.length <= 8); long v = 0; for (byte b : data) { v <<= 8; v = v | (b & 0x0FF); } return v; } 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 testToLong() { assertThat(BinaryType.toLong(new byte[] { (byte) 0x0FE, (byte) 0x0DC, (byte) 0x0BA, (byte) 0x098, 0x076, 0x054, 0x032, 0x010 })) .isEqualTo(0x0FEDCBA9876543210L); }