com.fasterxml.uuid
Class UUIDComparator
java.lang.Object
com.fasterxml.uuid.UUIDComparator
- All Implemented Interfaces:
- Comparator<UUID>
public class UUIDComparator
- extends Object
- implements 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
variants.
- Author:
- tatu
Method Summary |
int |
compare(UUID u1,
UUID u2)
|
protected static int |
compareUInts(int i1,
int i2)
|
protected static int |
compareULongs(long l1,
long l2)
|
static int |
staticCompare(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, wait |
UUIDComparator
public UUIDComparator()
compare
public int compare(UUID u1,
UUID u2)
- Specified by:
compare
in interface Comparator<UUID>
staticCompare
public static int staticCompare(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)
compareULongs
protected static final int compareULongs(long l1,
long l2)
compareUInts
protected static final int compareUInts(int i1,
int i2)
Copyright © 2011 FasterXML.com. All Rights Reserved.