/** * Returns the next monotonic value. If an overflow happened while incrementing * the random part of the given previous ULID value then the returned value will * have a zero random part. * * @param previousUlid the previous ULID value. * @param timestamp the timestamp of the next ULID value. * @return the next monotonic value. */ public Value nextMonotonicValue(Value previousUlid, long timestamp) { Objects.requireNonNull(previousUlid, "previousUlid must not be null!"); if(previousUlid.timestamp() == timestamp) { return previousUlid.increment(); } return nextValue(timestamp); }
/** * Returns the next monotonic value. If an overflow happened while incrementing * the random part of the given previous ULID value then the returned value will * have a zero random part. * * @param previousUlid the previous ULID value. * @param timestamp the timestamp of the next ULID value. * @return the next monotonic value. */ public Value nextMonotonicValue(Value previousUlid, long timestamp) { Objects.requireNonNull(previousUlid, "previousUlid must not be null!"); if(previousUlid.timestamp() == timestamp) { return previousUlid.increment(); } return nextValue(timestamp); }
@Override public String toString() { char[] buffer = new char[26]; internalWriteCrockford(buffer, timestamp(), 10, 0); long value = ((mostSignificantBits & 0xFFFFL) << 24); long interim = (leastSignificantBits >>> 40); value = value | interim; internalWriteCrockford(buffer, value, 8, 10); internalWriteCrockford(buffer, leastSignificantBits, 8, 18); return new String(buffer); } }
@Override public String toString() { char[] buffer = new char[26]; internalWriteCrockford(buffer, timestamp(), 10, 0); long value = ((mostSignificantBits & 0xFFFFL) << 24); long interim = (leastSignificantBits >>> 40); value = value | interim; internalWriteCrockford(buffer, value, 8, 10); internalWriteCrockford(buffer, leastSignificantBits, 8, 18); return new String(buffer); } }