Package de.aristaflow.adept2.util
Class UUIDTools
- java.lang.Object
-
- de.aristaflow.adept2.util.UUIDTools
-
public final class UUIDTools extends Object
Tool class for creating and managing UUIDs. Always use this class when in need of aUUID
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
UUIDTools.UUIDComparator
A UUID comparator comparing UUIDs unsigned, that is a leading 7 is less than a leading 8.
-
Field Summary
Fields Modifier and Type Field Description static int
FORBIDDEN_LONG
The constant value that must not occur as part of a created UUID.static UUID
NON_EXISTING_UUID
The UUID that will never exist, created with theFORBIDDEN_LONG
as most and least sig bits.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static UUID
createNegativeRandomUUID()
Creates a random UUID which has a negative sign, that means a special bit for distinguishing two complementary cases.static UUID
createNegativeRandomUUIDDebug()
Creates a consecutive UUID having a negative sign.static UUID
createPositiveUUID()
Creates a random UUID which has a positive sign, that means a special bit for distinguishing two complementary cases.static UUID
createPositiveUUIDDebug()
Creates a consecutive UUID having a positive sign.static UUID
createRandomUUID()
Creates a simple random UUID with no part of it beingFORBIDDEN_LONG
.static UUID
createRandomUUIDDebug()
Creates a consecutive UUID.static SerialisableComparator<UUID>
getUnsignedComparator()
Gets a new UUID comparator comparing UUIDs unsigned, that is a leading 7 is less than a leading 8.static boolean
isNegative(UUID uuid)
Returns whether the designated UUID is "negative", that is, it has a negative sign (the most significant bits are a negative long value).
-
-
-
Field Detail
-
FORBIDDEN_LONG
public static final int FORBIDDEN_LONG
The constant value that must not occur as part of a created UUID.- See Also:
- Constant Field Values
-
NON_EXISTING_UUID
public static final UUID NON_EXISTING_UUID
The UUID that will never exist, created with theFORBIDDEN_LONG
as most and least sig bits.
-
-
Method Detail
-
createRandomUUID
public static UUID createRandomUUID()
Creates a simple random UUID with no part of it beingFORBIDDEN_LONG
.- Returns:
- A simple random UUID with no part of it being
FORBIDDEN_LONG
. - See Also:
UUID.randomUUID()
-
createRandomUUIDDebug
public static UUID createRandomUUIDDebug()
Creates a consecutive UUID. This is useful for debugging purpose when using instead of a random UUID. The sequence will be reset when loading this class.- Returns:
- A consecutive UUID for debugging random UUIDs.
- See Also:
createRandomUUID()
-
createPositiveUUID
public static UUID createPositiveUUID()
Creates a random UUID which has a positive sign, that means a special bit for distinguishing two complementary cases. For instance, this can be used for unmodified instances while a modified instance can have a negative UUID.- Returns:
- A random "positive" UUID.
-
createPositiveUUIDDebug
public static UUID createPositiveUUIDDebug()
Creates a consecutive UUID having a positive sign. This is useful for debugging purpose when using instead of a random positive UUID.- Returns:
- A consecutive "positive" UUID.
- See Also:
createPositiveUUID()
-
createNegativeRandomUUID
public static UUID createNegativeRandomUUID()
Creates a random UUID which has a negative sign, that means a special bit for distinguishing two complementary cases. For instance, this can be used for modified instances while an unmodified instance can have a positive UUID.- Returns:
- A random "negative" UUID.
-
createNegativeRandomUUIDDebug
public static UUID createNegativeRandomUUIDDebug()
Creates a consecutive UUID having a negative sign. This is useful for debugging purpose when using instead of a random negative UUID.- Returns:
- A consecutive "negative" UUID.
- See Also:
createNegativeRandomUUID()
-
isNegative
public static boolean isNegative(UUID uuid)
Returns whether the designated UUID is "negative", that is, it has a negative sign (the most significant bits are a negative long value).- Parameters:
uuid
- The UUID to check whether it is negative.- Returns:
- Whether the designated UUID is "negative" (the most significant bits are a negative long value).
-
getUnsignedComparator
public static SerialisableComparator<UUID> getUnsignedComparator()
Gets a new 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.- Returns:
- A new UUID comparator comparing UUIDs unsigned
-
-