X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.api.uuid%2Fsrc%2Forg%2Fargeo%2Fapi%2Fuuid%2FTimeUuidState.java;h=9c8b6dd69b294b8eb56f8cf9b66d02ae388bd40f;hb=475dc8545eb01b541c63be6a480fdd8d808e75a4;hp=b926ccb3642d0c09a3098d05f3b5d4ab6ff92193;hpb=38414ed12442720c522f5cb6d89fbdb3010bf2f4;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.api.uuid/src/org/argeo/api/uuid/TimeUuidState.java b/org.argeo.api.uuid/src/org/argeo/api/uuid/TimeUuidState.java index b926ccb36..9c8b6dd69 100644 --- a/org.argeo.api.uuid/src/org/argeo/api/uuid/TimeUuidState.java +++ b/org.argeo.api.uuid/src/org/argeo/api/uuid/TimeUuidState.java @@ -3,6 +3,7 @@ package org.argeo.api.uuid; import java.time.Instant; import java.time.ZoneOffset; import java.time.ZonedDateTime; +import java.util.UUID; /** * The state of a time based UUID generator, as described and discussed in @@ -11,12 +12,28 @@ import java.time.ZonedDateTime; * @see https://datatracker.ietf.org/doc/html/rfc4122#section-4.2.1 */ public interface TimeUuidState { + long MOST_SIG_VERSION1 = (1l << 12); + long LEAST_SIG_RFC4122_VARIANT = (1l << 63); /** Start of the Gregorian time, used by time-based UUID (v1). */ final static Instant GREGORIAN_START = ZonedDateTime.of(1582, 10, 15, 0, 0, 0, 0, ZoneOffset.UTC).toInstant(); - long useTimestamp(); + /** Current node id and clock sequence for this thread. */ + long getLeastSignificantBits(); + /** A new current timestamp for this thread. */ + long getMostSignificantBits(); + + /** + * The last timestamp which was produced by this thread, as returned by + * {@link UUID#timestamp()}. + */ + long getLastTimestamp(); + + /** + * The current clock sequence for this thread, as returned by + * {@link UUID#clockSequence()}. + */ long getClockSequence(); static boolean isNoMacAddressNodeId(byte[] nodeId) {