Package com.fasterxml.uuid
Class UUIDComparator
java.lang.Object
com.fasterxml.uuid.UUIDComparator
- All Implemented Interfaces:
Comparator<UUID>
Default
UUID comparator is not very useful, since
it just does blind byte-by-byte comparison which does not work well
for time+location - based UUIDs. Additionally, it also uses signed
comparisons for longs which can lead to unexpected behavior
This comparator does implement proper lexical ordering: starting with
type (different types are collated
separately), followed by time and location (for time/location based),
and simple lexical (byte-by-byte) ordering for name/hash and random
versions.- Author:
- tatu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintprotected static final intcompareUInts(int i1, int i2) protected static final intcompareULongs(long l1, long l2) static intstaticCompare(UUID u1, UUID u2) Static helper method that can be used instead of instantiating comparator (used by unit tests, can be used by code too)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
UUIDComparator
public UUIDComparator()
-
-
Method Details
-
compare
- Specified by:
comparein interfaceComparator<UUID>
-
staticCompare
Static helper method that can be used instead of instantiating comparator (used by unit tests, can be used by code too) -
compareULongs
protected static final int compareULongs(long l1, long l2) -
compareUInts
protected static final int compareUInts(int i1, int i2)
-