Class UUIDs


  • public class UUIDs
    extends Object
    Utility class for working with UUID instances.
    • Constructor Detail

      • UUIDs

        public UUIDs()
    • Method Detail

      • 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:
        UUID.randomUUID()
      • isValidUUID

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

        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:
        UUID