Class UlidParser
java.lang.Object
cloud.opencode.base.id.ulid.UlidParser
- All Implemented Interfaces:
IdParser<String, UlidParser.ParsedUlid>
ULID Parser
ULID解析器
Parses ULID strings to extract timestamp and randomness components.
解析ULID字符串以提取时间戳和随机性组件。
Features | 主要功能:
- Extract timestamp - 提取时间戳
- Extract randomness - 提取随机性
- Validate format - 验证格式
Usage Examples | 使用示例:
UlidParser parser = UlidParser.create();
ParsedUlid parsed = parser.parse("01ARZ3NDEKTSV4RRFFQ69G5FAV");
System.out.println("Time: " + parsed.time());
System.out.println("Timestamp part: " + parsed.getTimestampPart());
System.out.println("Randomness part: " + parsed.getRandomnessPart());
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
Performance | 性能特性:
- Time complexity: O(1) - parse() decodes a fixed 26-character Crockford Base32 string using a pre-built static lookup table - 时间复杂度: O(1) - parse() 使用预构建静态查找表解码固定 26 字符的 Crockford Base32 字符串
- Space complexity: O(1) - produces a fixed-size ParsedUlid record - 空间复杂度: O(1) - 生成固定大小的 ParsedUlid 记录
- Since:
- JDK 25, opencode-base-id V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classParsed ULID Result 解析的ULID结果 -
Method Summary
Modifier and TypeMethodDescriptionstatic UlidParsercreate()Creates a ULID parser 创建ULID解析器extractTimestamp(String ulid) Extracts the timestamp from an ID 从ID中提取时间戳booleanValidates the ID format 验证ID格式Parses an ID to extract embedded information 解析ID以提取嵌入信息
-
Method Details
-
create
-
parse
Description copied from interface:IdParserParses an ID to extract embedded information 解析ID以提取嵌入信息- Specified by:
parsein interfaceIdParser<String, UlidParser.ParsedUlid>- Parameters:
ulid- the ID to parse | 要解析的ID- Returns:
- parse result | 解析结果
-
extractTimestamp
Description copied from interface:IdParserExtracts the timestamp from an ID 从ID中提取时间戳- Specified by:
extractTimestampin interfaceIdParser<String, UlidParser.ParsedUlid>- Parameters:
ulid- the ID | ID- Returns:
- timestamp | 时间戳
-
isValid
-