Code example for UUID

Methods: compareTo, version

0
 
    public void logJdkUUIDCompareToVariance(UUID u1, UUID u2, int expC)
    { 
        if ((u1 == null) || (u2 == null))
            return; 
        if (u1.version() != u2.version())
            return; 
        if (u1.version() == 1)
            return; 
        if (u1.compareTo(u2) != expC)
            logger.info("*** Note: java.util.UUID.compareTo() would have compared this differently");
    } 
 
    public void testCompare(UUID u1, UUID u2, int expC)
    { 
        int c = sign(uuidType.compare(bytebuffer(u1), bytebuffer(u2)));
        expC = sign(expC);
        assertEquals("Expected " + describeCompare(u1, u2, expC) + ", got " + describeCompare(u1, u2, c), expC, c);
 
        if (((u1 != null) && (u1.version() == 1)) && ((u2 != null) && (u2.version() == 1)))
            assertEquals(c, sign(TimeUUIDType.instance.compare(bytebuffer(u1), bytebuffer(u2))));