]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.api.acr/src/org/argeo/api/acr/uuid/TimeUuidState.java
Experiment with package level A2 metadata
[lgpl/argeo-commons.git] / org.argeo.api.acr / src / org / argeo / api / acr / uuid / TimeUuidState.java
1 package org.argeo.api.acr.uuid;
2
3 import java.time.Instant;
4 import java.time.ZoneOffset;
5 import java.time.ZonedDateTime;
6
7 /**
8 * The state of a time based UUID generator, as described and discussed in
9 * section 4.2.1 of RFC4122.
10 *
11 * @see https://datatracker.ietf.org/doc/html/rfc4122#section-4.2.1
12 */
13 public interface TimeUuidState {
14
15 /** Start of the Gregorian time, used by time-based UUID (v1). */
16 final static Instant GREGORIAN_START = ZonedDateTime.of(1582, 10, 15, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
17
18 long useTimestamp();
19
20 long getClockSequence();
21
22 static boolean isNoMacAddressNodeId(byte[] nodeId) {
23 return (nodeId[0] & 1) != 0;
24 }
25
26 static class Holder {
27 long lastTimestamp;
28 long clockSequence;
29
30 public long getLastTimestamp() {
31 return lastTimestamp;
32 }
33
34 public void setLastTimestamp(long lastTimestamp) {
35 this.lastTimestamp = lastTimestamp;
36 }
37
38 public long getClockSequence() {
39 return clockSequence;
40 }
41
42 public void setClockSequence(long clockSequence) {
43 this.clockSequence = clockSequence;
44 }
45
46 }
47 }