public static int compare ( UUID uuid1 , UUID uuid2 ) { int timeResult = Longs . compare ( uuid1 . timestamp ( ) , uuid2 . timestamp ( ) ) ; if ( timeResult != 0 ) { return timeResult ; } // if the time component is identical, break ties using the clockSeqAndNode // component (the 64 least significant bits). the top 16 bits of the lsb are // the "clockSeq" number which, theoretically, is an incrementing counter. in // practice, however, (and in com.eaio.uuid) clockSeq is a random number and // shouldn't be interpreted as meaning anything. just use it for breaking ties. return uuid1 . compareTo ( uuid2 ) ; }
Compare two time UUIDs deterministically first by their embedded timestamp next by their node - specific sequence number finally breaking ties using their embedded node identifier . \