Module com.github.f4b6a3.uuid
Interface NodeIdFunction
-
- All Superinterfaces:
LongSupplier
- All Known Implementing Classes:
DefaultNodeIdFunction,HashNodeIdFunction,MacNodeIdFunction,RandomNodeIdFunction
- 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 NodeIdFunction extends LongSupplier
Function that must return a number between 0 and 2^48-1.Example:
// A function that returns new random multicast node identifiers NodeIdFunction f = () -> NodeIdFunction.getMulticastRandom();
-
-
Method Summary
Static Methods Modifier and Type Method Description static longgetMulticastRandom()Return a new random multicast node identifier.static longgetRandom()Returns a new random node identifier.static booleanisMulticast(long nodeid)Checks if the multicast bit of a node identifier is set.static longtoExpectedRange(long nodeid)Clears the leading bits so that the resulting number is in the range 0 to 2^48-1.static longtoMulticast(long nodeid)Sets the multicast bit of a node identifier.-
Methods inherited from interface java.util.function.LongSupplier
getAsLong
-
-
-
-
Method Detail
-
getRandom
static long getRandom()
Returns a new random node identifier.- Returns:
- a number in the range 0 to 2^48-1.
-
getMulticastRandom
static long getMulticastRandom()
Return a new random multicast node identifier.- Returns:
- a number in the range 0 to 2^48-1.
-
toExpectedRange
static long toExpectedRange(long nodeid)
Clears the leading bits so that the resulting number is in the range 0 to 2^48-1.The result is equivalent to
n % 2^48.- Parameters:
nodeid- the node identifier- Returns:
- a number in the range 0 to 2^48-1.
-
toMulticast
static long toMulticast(long nodeid)
Sets the multicast bit of a node identifier.It also clears leading bits so that the resulting number is within the range 0 to 2^48-1.
- Parameters:
nodeid- the node identifier- Returns:
- a node identifier with the multicast bit set
-
isMulticast
static boolean isMulticast(long nodeid)
Checks if the multicast bit of a node identifier is set.- Parameters:
nodeid- a node identifier- Returns:
- true if the node identifier is multicast
-
-