public static byte[] hashUUID(PrimaryKey primaryKey) {
    Object[] values = primaryKey.getValues();
    byte[] result = new byte[values.length * 16];
    ByteBuffer byteBuffer = ByteBuffer.wrap(result).order(ByteOrder.BIG_ENDIAN);
    for (Object value : values) {
      if (value == null) {
        throw new IllegalArgumentException("Found null value in primary key");
      }
      UUID uuid;
      try {
        uuid = UUID.fromString(value.toString());
      } catch (Throwable t) {
        return primaryKey.asBytes();
      }
      byteBuffer.putLong(uuid.getMostSignificantBits());
      byteBuffer.putLong(uuid.getLeastSignificantBits());
    }
    return result;
  }
@Test
  public void testHashUUID() {
    // Test happy cases: when all UUID values are valid
    testHashUUID(new UUID[]{UUID.randomUUID()});
    testHashUUID(new UUID[]{UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()});

    // Test failure scenario when there's a non-null invalid uuid value
    PrimaryKey invalidUUIDs = new PrimaryKey(new String[]{"some-random-string"});
    byte[] hashResult = HashUtils.hashUUID(invalidUUIDs);
    // In case of failures, each element is prepended with length
    byte[] expectedResult = invalidUUIDs.asBytes();
    assertEquals(hashResult, expectedResult);
    // Test failure scenario when one of the values is null
    try {
      PrimaryKey pKeyWithNull = new PrimaryKey(new String[]{UUID.randomUUID().toString(), null});
      HashUtils.hashUUID(pKeyWithNull);
      fail("Should have thrown an exception");
    } catch (IllegalArgumentException e) {
      assertTrue(e.getMessage().contains("Found null value"));
    }
  }