Skip to navigation

UUID

View as Markdown
global class UUID
Description
Represents a UUID/GUID.

Methods

global static UUID parse(final String s)
Description
Parses a string as a UUID. Throws a StringException if the input string is blank or does not match the UUID pattern.
Returns
The parsed UUID, assuming the input string is valid.
Parameters
s
final String s
The input string matching the pattern [0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}.
global static UUID randomUUID()
Description
Generates a cryptographically-random UUID. Useful for generating secrets or unit testing methods requiring a UUID argument.
Returns
The generated UUID.
global static UUID tryParse(final String s)
Description
Attempts to parse a string as a UUID.
Returns
The parsed UUID if the input string is valid, or null if the input string is invalid.
Parameters
s
final String s
The input string matching the pattern [0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}.