Class UUIDs

java.lang.Object
org.kiwiproject.base.UUIDs

public final class UUIDs extends Object
Utility class for working with UUID instances.
  • Method Details

    • randomUUIDString

      public static String randomUUIDString()
      Creates a new type 4 (pseudo randomly generated) UUID, and then returns it as a string.
      Returns:
      a new random UUID as a String
      See Also:
    • isValidUUID

      public static boolean isValidUUID(String value)
      Checks if the value is a valid UUID conforming to RFC 4122. The general form is 8-4-4-4-12 where all the digits are hexadecimal. Example: e94c302e-e684-4d72-9060-a66461f858d6

      Note specifically that this method does not support the Nil UUID and will always return false if given a Nil UUID.

      This method has been tested with UUIDs generated using UUID.randomUUID() and UUID.nameUUIDFromBytes(byte[]). It has also been tested with UUIDs created using the constructor UUID(long, long) with the caveat that the most and least significant bits came from valid type 3 and 4 UUIDs.

      Parameters:
      value - the string to check
      Returns:
      true if a valid UUID, false otherwise
      See Also:
    • isValidUUIDAllowingNil

      public static boolean isValidUUIDAllowingNil(String value)
      Checks if the value is a valid UUID conforming to RFC 4122 (including the Nil UUID). The general form is 8-4-4-4-12 where all the digits are hexadecimal. Example: e94c302e-e684-4d72-9060-a66461f858d6, or the nil UUID 00000000-0000-0000-0000-000000000000.

      This method has been tested with UUIDs generated using UUID.randomUUID() and UUID.nameUUIDFromBytes(byte[]). It has also been tested with UUIDs created using the constructor UUID(long, long) with the caveat that the most and least significant bits came from valid type 3 and 4 UUIDs.

      Parameters:
      value - the string to check
      Returns:
      true if a valid UUID, false otherwise
      See Also: