Class UuidGenerator
java.lang.Object
cloud.opencode.base.id.uuid.UuidGenerator
- All Implemented Interfaces:
IdGenerator<UUID>
UUID Generator
UUID生成器
Unified UUID generator supporting both v4 (random) and v7 (time-ordered).
统一的UUID生成器,支持v4(随机)和v7(时间有序)。
Features | 主要功能:
- UUID v4 - Random UUID | 随机UUID
- UUID v7 - Time-ordered UUID | 时间有序UUID
- Multiple output formats - 多种输出格式
Usage Examples | 使用示例:
// UUID v4
UuidGenerator v4 = UuidGenerator.v4();
UUID uuid = v4.generate();
// UUID v7
UuidGenerator v7 = UuidGenerator.v7();
UUID uuidV7 = v7.generate();
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Since:
- JDK 25, opencode-base-id V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiongenerate()Generates the next ID 生成下一个IDGenerates a simple UUID (no hyphens) 生成简化UUID(无连字符)Generates a UUID as string 生成UUID字符串getType()Gets the generator type name 获取生成器类型名称intGets the UUID version 获取UUID版本static UuidGeneratorv4()Creates a UUID v4 generator 创建UUID v4生成器static UuidGeneratorv7()Creates a UUID v7 generator 创建UUID v7生成器Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IdGenerator
generateBatch
-
Method Details
-
v4
-
v7
-
generate
Description copied from interface:IdGeneratorGenerates the next ID 生成下一个ID- Specified by:
generatein interfaceIdGenerator<UUID>- Returns:
- generated ID | 生成的ID
-
generateStr
-
generateSimple
Generates a simple UUID (no hyphens) 生成简化UUID(无连字符)- Returns:
- simple UUID string | 简化UUID字符串
-
getVersion
public int getVersion()Gets the UUID version 获取UUID版本- Returns:
- version number | 版本号
-
getType
Description copied from interface:IdGeneratorGets the generator type name 获取生成器类型名称- Specified by:
getTypein interfaceIdGenerator<UUID>- Returns:
- type name | 类型名称
-