Module buralotech.identifier.core
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 TypeMethodDescriptionbyte[]fromTicks(long ticks, long suffix) Create a UUID as a byte array from a timestamp.byte[]generate()Generate an identifier using an underlying UUID generator.booleanisValidBinary(byte[] binary) Check that the binary representation is valid.booleanisValidText(String text) 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:
trueif the binary representation is valid. Otherwise,false.
-
isValidText
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:
trueif the text representation is valid. Otherwise,false.
-
toInstant
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.
-