Serializer { public static byte[] getFiveBytes(long value) { if (value < 0) { throw new IllegalArgumentException("negative value not allowed: " + value); } else if (value > 1099511627775L) { throw new IllegalArgumentException("value out of range: " + value); } return new byte[] { (byte) (value >> 32), (byte) (value >> 24), (byte) (value >> 16), (byte) (value >> 8), (byte) value }; } private  Serializer(); static byte[] getBytes(int value); static byte[] getBytes(long value); static byte[] getBytes(short value); static byte[] getFiveBytes(long value); static byte[] getVariableByteSigned(int value); static byte[] getVariableByteUnsigned(int value);  }
@Test public void getFiveBytesTest() { byte[] fiveBytes = Serializer.getFiveBytes(0); Assert.assertArrayEquals(new byte[] { 0, 0, 0, 0, 0 }, fiveBytes); fiveBytes = Serializer.getFiveBytes(5); Assert.assertArrayEquals(new byte[] { 0, 0, 0, 0, 5 }, fiveBytes); }