Class 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)
    • 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​(Random random,
                                       Clock clock)
      • 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

      • create

        public UUID create()
        Returns a time-ordered unique identifier (UUIDv7).
        Returns:
        a UUIDv7