Module com.github.f4b6a3.uuid
Interface ClockSeqFunction
-
- All Superinterfaces:
LongUnaryOperator
- All Known Implementing Classes:
DefaultClockSeqFunction
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface ClockSeqFunction extends LongUnaryOperator
It must return a number between 0 and 16383 (2^14-1). It receives as argument the current 100-nanoseconds since 1970-01-01 (Unix epoch). UsetoExpectedRange(long)to set the output within the range 0 to 16383 (2^14-1). Examples:// A `ClockSeqFunction` that always returns a random number between 0 and 16383 (2^14-1). ClockSeqFunction f = unix100Nanos -> ClockSeqFunction.getRandom();
// A `ClockSeqFunction` that always returns the same number between 0 and 16383 (2^14-1). final long number = 1234; ClockSeqFunction f = unix100Nanos -> ClockSeqFunction.toExpectedRange(number);
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classClockSeqFunction.ClockSeqPoolClass that manages the usage of clock sequence values from 0 to 16383.
-
Method Summary
Static Methods Modifier and Type Method Description static longgetRandom()This method return a new random clock sequence.static longtoExpectedRange(long clockseq)This method clears the unnecessary leading bits so that the resulting number is within the range 0 to 16383 (2^14-1).-
Methods inherited from interface java.util.function.LongUnaryOperator
andThen, applyAsLong, compose
-
-
-
-
Method Detail
-
getRandom
static long getRandom()
This method return a new random clock sequence.- Returns:
- a clock sequence in the range 0 to 16383 (2^14-1).
-
toExpectedRange
static long toExpectedRange(long clockseq)
This method clears the unnecessary leading bits so that the resulting number is within the range 0 to 16383 (2^14-1). The result is equivalent ton % 2^14.- Parameters:
clockseq- the clock sequence- Returns:
- a clock sequence in the range 0 to 16383 (2^14-1).
-
-