UuidUtil { public static byte[] uuidToByteArray(final UUID uuid) { final ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]); byteBuffer.putLong(uuid.getMostSignificantBits()); byteBuffer.putLong(uuid.getLeastSignificantBits()); return byteBuffer.array(); } private  UuidUtil(); static Object makeUuid(final String databaseName); static byte[] uuidToByteArray(final UUID uuid);  }
@Test public void roundtripUuid() throws Exception { final UUID originalUuid = UUID.randomUUID(); final byte[] translatedUuid = UuidUtil.uuidToByteArray(originalUuid); final ByteBuffer buffer = ByteBuffer.wrap(translatedUuid); assertThat(new UUID(buffer.getLong(), buffer.getLong()), equalTo(originalUuid)); }