static Value internalNextValue(long timestamp, Random random) { checkTimestamp(timestamp); // could use nextBytes(byte[] bytes) instead long mostSignificantBits = random.nextLong(); long leastSignificantBits = random.nextLong(); mostSignificantBits &= 0xFFFF; mostSignificantBits |= (timestamp << 16); return new Value(mostSignificantBits, leastSignificantBits); }
static Value internalNextValue(long timestamp, Random random) { checkTimestamp(timestamp); // could use nextBytes(byte[] bytes) instead long mostSignificantBits = random.nextLong(); long leastSignificantBits = random.nextLong(); mostSignificantBits &= 0xFFFF; mostSignificantBits |= (timestamp << 16); return new Value(mostSignificantBits, leastSignificantBits); }
static String internalUIDString(long timestamp, Random random) { checkTimestamp(timestamp); char[] buffer = new char[26]; internalWriteCrockford(buffer, timestamp, 10, 0); // could use nextBytes(byte[] bytes) instead internalWriteCrockford(buffer, random.nextLong(), 8, 10); internalWriteCrockford(buffer, random.nextLong(), 8, 18); return new String(buffer); }
static String internalUIDString(long timestamp, Random random) { checkTimestamp(timestamp); char[] buffer = new char[26]; internalWriteCrockford(buffer, timestamp, 10, 0); // could use nextBytes(byte[] bytes) instead internalWriteCrockford(buffer, random.nextLong(), 8, 10); internalWriteCrockford(buffer, random.nextLong(), 8, 18); return new String(buffer); }
static void internalAppendULID(StringBuilder builder, long timestamp, Random random) { checkTimestamp(timestamp); internalAppendCrockford(builder, timestamp, 10); // could use nextBytes(byte[] bytes) instead internalAppendCrockford(builder, random.nextLong(), 8); internalAppendCrockford(builder, random.nextLong(), 8); }
static void internalAppendULID(StringBuilder builder, long timestamp, Random random) { checkTimestamp(timestamp); internalAppendCrockford(builder, timestamp, 10); // could use nextBytes(byte[] bytes) instead internalAppendCrockford(builder, random.nextLong(), 8); internalAppendCrockford(builder, random.nextLong(), 8); }