Class Uuid

extends Object
A universally unique identifier, UUID.
UUIDs are equivalent to a 128-bit number. Through the use of cryptographic hash functions (for version 5, SHA1) UUIDs are practically unique.

Class summary


constructor bytes_/ByteArray
Creates a UUID from bytes_.

Constructors

Creates a UUID from bytes_.
The given parameter must be a byte array of size 16.

Statics

Returns whether the given str is a valid UUID.

NIL -> any
The Nil UUID.
This UUID is composed of all bits set to zero.

parse str/string [--on-error] -> Uuid
Deprecated. Use parse str [--if-error] instead.

parse str/string [--if-error] -> Uuid
Parses the given str as a UUID.
Supports the canonical textual representation, consisting of 16 bytes encoded as 32 hexademical values. The hexadecimal values should be split into 5 groups, separated by a dash ('-'). The groups should contain respectively 8, 4, 4, 4, and 12 hexadecimal characters.
Calls if-error (and returns its result) if str is not a valid UUID.
Examples

parse "123e4567-e89b-12d3-a456-426614174000"

Variant of parse str [--if-error] that throws an error if str is not a valid UUID.

Generates a random UUID.

SIZE -> any
Bytesize of a UUID.

uuid5 namespace/Data data/Data -> Uuid
Builds a version 5 UUID from the given namespace and data.
The generated UUID uses the variant 1 (RFC 4122/DCE 1.1), and is thus also known as "Leach-Salz" UUID.

Methods

A hash code for this instance.

Whether this instance is equal to the nil UUID NIL.

operator == other/any -> bool
Whether this instance has the same 128 bits as other.

Converts this instance to a string.
Use to-string to get the canonical text representation of UUIDs.

Converts this instance into a byte array.
The returned byte array is 16 bytes long and contains the 128 bits of this UUID.
The returned byte array is a valid input for the UUID constructor.

Converts this instance to the canonical text representation of UUIDs.
Converts the 128 bits of this instance into hexadecimal values, and groups
them in 8, 4, 4, 4, and 12 character segments, each separated by a "-".
For example, a result of this method could be: "123e4567-e89b-12d3-a456-426614174000"