]> git.argeo.org Git - lgpl/argeo-commons.git/blob - NodeIdSupplier.java
ae9686c7042781348643295ef29f58a302b510b6
[lgpl/argeo-commons.git] / NodeIdSupplier.java
1 package org.argeo.api.uuid;
2
3 import java.util.function.Supplier;
4
5 /** A factory for node id base */
6 public interface NodeIdSupplier extends Supplier<Long> {
7 long LEAST_SIG_RFC4122_VARIANT = (1l << 63);
8
9 static long toNodeIdBase(byte[] node) {
10 assert node.length == 6;
11 return LEAST_SIG_RFC4122_VARIANT // base for Leach–Salz UUID
12 | (node[0] & 0xFFL) //
13 | ((node[1] & 0xFFL) << 8) //
14 | ((node[2] & 0xFFL) << 16) //
15 | ((node[3] & 0xFFL) << 24) //
16 | ((node[4] & 0xFFL) << 32) //
17 | ((node[5] & 0xFFL) << 40); //
18 }
19
20 }