Class StandardStringCodec

  • All Implemented Interfaces:
    UuidCodec<String>

    public class StandardStringCodec
    extends Object
    implements UuidCodec<String>
    Codec for UUID canonical string as defined in RFC 9562.

    In the canonical textual representation, the 16 bytes of a UUID are represented as 32 hexadecimal (base-16) digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 hexadecimal characters and 4 hyphens).

    This codec decodes (parses) strings in these formats:

    • 000000000000V0000000000000000000 (hexadecimal string)
    • 00000000-0000-0000-0000-000000000000 (THE canonical string)
    • {00000000-0000-0000-0000-000000000000} (Microsoft string)
    • urn:uuid:00000000-0000-0000-0000-000000000000 (URN string)

    The encoding and decoding processes can be much faster (7x) than UUID.toString() and UUID.fromString(String) in JDK 8.

    If you prefer a string representation without hyphens, use Base16Codec instead of StandardStringCodec. Base16Codec can be much faster (22x) than doing uuid.toString().replaceAll("-", "").

    See Also:
    RFC 9562
    • Constructor Detail

      • StandardStringCodec

        public StandardStringCodec()