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 a UUID.
  • Field Details

    • FORBIDDEN_LONG

      public static final int FORBIDDEN_LONG
      The constant value that must not occur as part of a created UUID.
      See Also:
    • NON_EXISTING_UUID

      public static final UUID NON_EXISTING_UUID
      The UUID that will never exist, created with the FORBIDDEN_LONG as most and least sig bits.
  • Method Details

    • createRandomUUID

      public static UUID createRandomUUID()
      Creates a simple random UUID with no part of it being FORBIDDEN_LONG.
      Returns:
      A simple random UUID with no part of it being FORBIDDEN_LONG.
      See Also:
    • 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:
    • 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:
    • 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:
    • 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