Module com.github.f4b6a3.uuid
Class TimeOrderedEpochFactory
- java.lang.Object
-
- com.github.f4b6a3.uuid.factory.UuidFactory
-
- com.github.f4b6a3.uuid.factory.AbstRandomBasedFactory
-
- com.github.f4b6a3.uuid.factory.AbstCombFactory
-
- com.github.f4b6a3.uuid.factory.rfc4122.TimeOrderedEpochFactory
-
- All Implemented Interfaces:
NoArgsFactory
public final class TimeOrderedEpochFactory extends AbstCombFactory
Concrete factory for creating Unix epoch time-ordered unique identifiers (UUIDv7).UUIDv7 is a new UUID version proposed by Peabody and Davis. It is similar to Prefix COMB GUID and ULID.
This factory creates 3 types:
- Type 1 (default): this type is divided in 3 components, namely time, counter and random. The counter component is incremented by 1 when the time repeats. The random component is always randomized.
- Type 2 (plus 1): this type is divided in 2 components, namely time and monotonic random. The monotonic random component is incremented by 1 when the time repeats. This type of UUID is like a Monotonic ULID. It can be much faster than the other types.
- Type 3 (plus n): this type is also divided in 2 components, namely time and monotonic random. The monotonic random component is incremented by a random positive integer between 1 and MAX when the time repeats. If the value of MAX is not specified, MAX is 2^32. This type of UUID is also like a Monotonic ULID.
Warning: this can change in the future.
- Since:
- 5.0.0
- See Also:
PrefixCombFactory, ULID Specification, New UUID formats, Revise Universally Unique Identifier Definitions (uuidrev)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTimeOrderedEpochFactory.BuilderConcrete builder for creating a Unix epoch time-ordered factory.-
Nested classes/interfaces inherited from class com.github.f4b6a3.uuid.factory.AbstRandomBasedFactory
AbstRandomBasedFactory.ByteRandom, AbstRandomBasedFactory.IRandom, AbstRandomBasedFactory.LongRandom
-
-
Field Summary
Fields Modifier and Type Field Description protected static intCLOCK_DRIFT_TOLERANCE-
Fields inherited from class com.github.f4b6a3.uuid.factory.AbstCombFactory
clock, DEFAULT_CLOCK
-
Fields inherited from class com.github.f4b6a3.uuid.factory.AbstRandomBasedFactory
random, UUID_BYTES
-
Fields inherited from class com.github.f4b6a3.uuid.factory.UuidFactory
version, versionMask
-
-
Constructor Summary
Constructors Constructor Description TimeOrderedEpochFactory()TimeOrderedEpochFactory(Clock clock)TimeOrderedEpochFactory(IntFunction<byte[]> randomFunction)TimeOrderedEpochFactory(IntFunction<byte[]> randomFunction, Clock clock)TimeOrderedEpochFactory(LongSupplier randomFunction)TimeOrderedEpochFactory(LongSupplier randomFunction, Clock clock)TimeOrderedEpochFactory(Random random)TimeOrderedEpochFactory(Random random, Clock clock)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TimeOrderedEpochFactory.Builderbuilder()Returns a builder of Unix epoch time-ordered factory.UUIDcreate()Returns a time-ordered unique identifier (UUIDv7).-
Methods inherited from class com.github.f4b6a3.uuid.factory.UuidFactory
getVersion, toUuid
-
-
-
-
Field Detail
-
CLOCK_DRIFT_TOLERANCE
protected static final int CLOCK_DRIFT_TOLERANCE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TimeOrderedEpochFactory
public TimeOrderedEpochFactory()
-
TimeOrderedEpochFactory
public TimeOrderedEpochFactory(Clock clock)
-
TimeOrderedEpochFactory
public TimeOrderedEpochFactory(Random random)
-
TimeOrderedEpochFactory
public TimeOrderedEpochFactory(LongSupplier randomFunction)
-
TimeOrderedEpochFactory
public TimeOrderedEpochFactory(IntFunction<byte[]> randomFunction)
-
TimeOrderedEpochFactory
public TimeOrderedEpochFactory(LongSupplier randomFunction, Clock clock)
-
TimeOrderedEpochFactory
public TimeOrderedEpochFactory(IntFunction<byte[]> randomFunction, Clock clock)
-
-
Method Detail
-
builder
public static TimeOrderedEpochFactory.Builder builder()
Returns a builder of Unix epoch time-ordered factory.- Returns:
- a builder
-
create
public UUID create()
Returns a time-ordered unique identifier (UUIDv7).- Returns:
- a UUIDv7
-
-