BinaryType implements Binary { public static byte[] toBytes(long value) { long v = value; byte[] bytes = new byte[8]; for (int i = 7; i >= 0; i--) { bytes[i] = (byte) v; v >>= 8; } return bytes; } 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 testToBytes() { assertThat(BinaryType.toBytes(0x0FEDCBA98)).containsExactly(0x0FE, 0x0DC, 0x0BA, 0x098); assertThat(BinaryType.toBytes(0x0FEDCBA9876543210L)).containsExactly(0x0FE, 0x0DC, 0x0BA, 0x098, 0x076, 0x054, 0x032, 0x010); }