Class ULIDGenerator
java.lang.Object
icu.congee.id.generator.ulid.ULIDGenerator
- All Implemented Interfaces:
IdGenerator
ULID (Universally Unique Lexicographically Sortable Identifier) 生成器
ULID是一种基于时间戳的、可排序的唯一标识符,由26个字符组成,包含:
- 10个字符的时间戳(精确到毫秒)
- 16个字符的随机数
特点:
- 按时间戳排序
- 使用Crockford的Base32编码
- 128位兼容UUID
- 无特殊字符
- Author:
- shamil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreate()返回一个使用Crockford的base32表示法编码的ULID字符串。generate()生成一个唯一标识符。idType()获取当前生成器的标识符类型static boolean检查字符串是否为有效的ULID。next()返回一个单调递增的ULID字符串,使用Crockford的base32表示法编码。voidreseed()protected static longtoLong(char[] input) 将base32字符数组解码为长整数。static long从ULID字符串中提取时间组件。Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface icu.congee.id.base.IdGenerator
generate
-
Constructor Details
-
ULIDGenerator
public ULIDGenerator() -
ULIDGenerator
-
-
Method Details
-
create
返回一个使用Crockford的base32表示法编码的ULID字符串。 -
next
返回一个单调递增的ULID字符串,使用Crockford的base32表示法编码。 -
reseed
public void reseed() -
unixTime
从ULID字符串中提取时间组件。 -
isValid
检查字符串是否为有效的ULID。 -
toLong
protected static long toLong(char[] input) 将base32字符数组解码为长整数。 -
generate
Description copied from interface:IdGenerator生成一个唯一标识符。 每个实现类都应该根据其特定的生成策略来实现此方法。- Specified by:
generatein interfaceIdGenerator- Returns:
- 生成的唯一标识符,具体类型由实现类决定
-
idType
Description copied from interface:IdGenerator获取当前生成器的标识符类型此方法用于标识生成器使用的具体ID生成策略。每个实现类都应该 返回一个对应其生成策略的IdType枚举值。
- Specified by:
idTypein interfaceIdGenerator- Returns:
- 当前生成器的标识符类型
-