1 package org
.argeo
.api
.uuid
;
3 import java
.time
.Instant
;
4 import java
.time
.ZoneOffset
;
5 import java
.time
.ZonedDateTime
;
9 * The state of a time based UUID generator, as described and discussed in
10 * section 4.2.1 of RFC4122.
12 * @see https://datatracker.ietf.org/doc/html/rfc4122#section-4.2.1
14 public interface TimeUuidState
{
15 long MOST_SIG_VERSION1
= (1l << 12);
16 long LEAST_SIG_RFC4122_VARIANT
= (1l << 63);
18 /** Start of the Gregorian time, used by time-based UUID (v1). */
19 final static Instant GREGORIAN_START
= ZonedDateTime
.of(1582, 10, 15, 0, 0, 0, 0, ZoneOffset
.UTC
).toInstant();
21 /** Current node id and clock sequence for this thread. */
22 long getLeastSignificantBits();
24 /** A new current timestamp for this thread. */
25 long getMostSignificantBits();
28 * The last timestamp which was produced by this thread, as returned by
29 * {@link UUID#timestamp()}.
31 long getLastTimestamp();
34 * The current clock sequence for this thread, as returned by
35 * {@link UUID#clockSequence()}.
37 long getClockSequence();
39 static boolean isNoMacAddressNodeId(byte[] nodeId
) {
40 return (nodeId
[0] & 1) != 0;