Class DotNetGuid1Codec

    • Field Detail

      • INSTANCE

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

      • DotNetGuid1Codec

        public DotNetGuid1Codec()
    • Method Detail

      • encode

        public UUID encode​(UUID uuid)
        Get a .Ned Guid from a time-based UUID (v1).

        This codec converts a time-based UUID (v1) to a .Net Guid.

        It rearranges the most significant bytes from big-endian to little-endian, and vice-versa.

        The .Net Guid stores the most significant bytes as little-endian, while the least significant bytes are stored as big-endian (network order).

        Specified by:
        encode in interface UuidCodec<UUID>
        Parameters:
        uuid - a UUID
        Returns:
        another UUID
        Throws:
        InvalidUuidException - if the argument is invalid
      • decode

        public UUID decode​(UUID uuid)
        Get a time-based UUID (v4) from a .Net Guid.

        It rearranges the most significant bytes from big-endian to little-endian, and vice-versa.

        The .Net Guid stores the most significant bytes as little-endian, while the least significant bytes are stored as big-endian (network order).

        Specified by:
        decode in interface UuidCodec<UUID>
        Parameters:
        uuid - a UUID
        Returns:
        another UUID
        Throws:
        InvalidUuidException - if the argument is invalid
      • toAndFromDotNetGuid

        protected static UUID toAndFromDotNetGuid​(UUID uuid)
        Convert a UUID to and from a .Net Guid.

        It rearranges the most significant bytes from big-endian to little-endian, and vice-versa.

        The .Net Guid stores the most significant bytes as little-endian, while the least significant bytes are stored as big-endian (network order).

        Parameters:
        uuid - a UUID
        Returns:
        another UUID
        See Also:
        How to Generate Sequential GUIDs for SQL Server in .NET, How are GUIDs sorted by SQL Server?