Class BinaryCodec

  • All Implemented Interfaces:
    UuidCodec<byte[]>

    public class BinaryCodec
    extends Object
    implements UuidCodec<byte[]>
    Codec for UUID binary encoding as defined in the RFC-4122.

    The UUID is encoded as 16 octets (bytes).

    • Field Detail

      • INSTANCE

        public static final BinaryCodec INSTANCE
        A shared immutable instance.
    • Constructor Detail

      • BinaryCodec

        public BinaryCodec()
    • Method Detail

      • encode

        public byte[] encode​(UUID uuid)
        Get an array of bytes from a UUID.
        Specified by:
        encode in interface UuidCodec<byte[]>
        Parameters:
        uuid - a UUID
        Returns:
        an array of bytes
        Throws:
        InvalidUuidException - if the argument is invalid
      • decode

        public UUID decode​(byte[] bytes)
        Get a UUID from an array of bytes.
        Specified by:
        decode in interface UuidCodec<byte[]>
        Parameters:
        bytes - an array of bytes
        Returns:
        a UUID
        Throws:
        InvalidUuidException - if the argument is invalid