Package de.aristaflow.adept2.util
Class UUIDTools.UUIDComparator
- java.lang.Object
-
- de.aristaflow.adept2.util.UUIDTools.UUIDComparator
-
- All Implemented Interfaces:
SerialisableComparator<UUID>
,Serializable
,Comparator<UUID>
- Enclosing class:
- UUIDTools
protected static class UUIDTools.UUIDComparator extends Object implements SerialisableComparator<UUID>
A UUID comparator comparing UUIDs unsigned, that is a leading 7 is less than a leading 8. Signed it would be vice versa since 8 is negative.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
UUIDComparator()
Creates a new UUID comparator comparing UUIDs unsigned, that is a leading 7 is less than a leading 8.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(UUID u1, UUID u2)
protected int
compareUnsigned(long l1, long l2)
Compares the designated longs unsigned, that is all negative longs will be greater than all positive longs and negative longs will be reverse ordered, that is numerical less will be more.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Method Detail
-
compareUnsigned
protected int compareUnsigned(long l1, long l2)
Compares the designated longs unsigned, that is all negative longs will be greater than all positive longs and negative longs will be reverse ordered, that is numerical less will be more. This allows for a nice ordering of the string representations of UUIDs.- Parameters:
l1
- The first long to compare.l2
- The second long to compare.- Returns:
- -1 if the first long is less than the second, 0 if both are equal and 1 if the first long is greater than the second, all treated unsigned.
-
compare
public int compare(UUID u1, UUID u2)
- Specified by:
compare
in interfaceComparator<UUID>
-
-