/** * 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. * @return the next monotonic value. */ public Value nextMonotonicValue(Value previousUlid) { return nextMonotonicValue(previousUlid, System.currentTimeMillis()); }
/** * 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. * @return the next monotonic value. */ public Value nextMonotonicValue(Value previousUlid) { return nextMonotonicValue(previousUlid, System.currentTimeMillis()); }
/** * Returns the next monotonic value or empty if an overflow happened while incrementing * the random part of the given previous ULID value. * * @param previousUlid the previous ULID value. * @param timestamp the timestamp of the next ULID value. * @return the next monotonic value or empty if an overflow happened. */ public Optional<Value> nextStrictlyMonotonicValue(Value previousUlid, long timestamp) { Value result = nextMonotonicValue(previousUlid, timestamp); if(result.compareTo(previousUlid) < 1) { return Optional.empty(); } return Optional.of(result); }
/** * Returns the next monotonic value or empty if an overflow happened while incrementing * the random part of the given previous ULID value. * * @param previousUlid the previous ULID value. * @param timestamp the timestamp of the next ULID value. * @return the next monotonic value or empty if an overflow happened. */ public Optional<Value> nextStrictlyMonotonicValue(Value previousUlid, long timestamp) { Value result = nextMonotonicValue(previousUlid, timestamp); if(result.compareTo(previousUlid) < 1) { return Optional.empty(); } return Optional.of(result); }