Interface UUIDVersionDelegate

All Known Implementing Classes:
UUIDVersion1Delegate, UUIDVersion6Delegate, UUIDVersion7Delegate

public interface UUIDVersionDelegate
Implementations encapsulate logic that is specific to the UUID format.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    fromTicks(long ticks, long suffix)
    Create a UUID as a byte array from a timestamp.
    byte[]
    Generate an identifier using an underlying UUID generator.
    boolean
    isValidBinary(byte[] binary)
    Check that the binary representation is valid.
    boolean
    Check that the text representation is valid.
    toInstant(byte[] binary)
    Extract the timestamp from the UUID.
  • Method Details

    • generate

      byte[] generate()
      Generate an identifier using an underlying UUID generator.
      Returns:
      The generated identifier as a byte array.
    • isValidBinary

      boolean isValidBinary(byte[] binary)
      Check that the binary representation is valid. The service has already checked that it is non-null and a valid length.
      Parameters:
      binary - The binary representation.
      Returns:
      true if the binary representation is valid. Otherwise, false.
    • isValidText

      boolean isValidText(String text)
      Check that the text representation is valid. The service has already checked that it is non-null and a valid length.
      Parameters:
      text - The binary representation.
      Returns:
      true if the text representation is valid. Otherwise, false.
    • toInstant

      Instant toInstant(byte[] binary)
      Extract the timestamp from the UUID.
      Parameters:
      binary - The binary representation of the UUID.
      Returns:
      The timestamp as an Instant.
    • fromTicks

      byte[] fromTicks(long ticks, long suffix)
      Create a UUID as a byte array from a timestamp.
      Parameters:
      ticks - The timestamp in 100 nanoseconds.
      suffix - The second portion of the UUID.
      Returns:
      The UUID as a byte array.