Class ObjectIdGenerators.StringIdGenerator
java.lang.Object
cloud.opencode.base.json.identity.ObjectIdGenerator<String>
cloud.opencode.base.json.identity.ObjectIdGenerators.StringIdGenerator
- Enclosing class:
ObjectIdGenerators
String ID Generator - String-Based Object IDs
字符串 ID 生成器 - 基于字符串的对象 ID
Generates string identifiers using UUID-based random strings.
使用基于 UUID 的随机字符串生成字符串标识符。
- Since:
- JDK 25, opencode-base-json V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class ObjectIdGenerator
ObjectIdGenerator.IdKey -
Constructor Summary
ConstructorsConstructorDescriptionCreates a generator with default scope (Object.class).StringIdGenerator(Class<?> scope) Creates a generator with the specified scope. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanUseFor(ObjectIdGenerator<?> gen) Determines whether this generator can be used interchangeably with another.generateId(Object forPojo) Generates a unique identifier for the given object.Class<?> getScope()Returns the scope class used to determine ID uniqueness boundaries.
-
Constructor Details
-
StringIdGenerator
public StringIdGenerator()Creates a generator with default scope (Object.class). 创建具有默认作用域(Object.class)的生成器。 -
StringIdGenerator
Creates a generator with the specified scope. 创建具有指定作用域的生成器。- Parameters:
scope- the scope class - 作用域类
-
-
Method Details
-
generateId
Description copied from class:ObjectIdGeneratorGenerates a unique identifier for the given object. 为给定对象生成唯一标识符。- Specified by:
generateIdin classObjectIdGenerator<String>- Parameters:
forPojo- the object to generate an ID for - 要生成 ID 的对象- Returns:
- the generated identifier - 生成的标识符
-
getScope
Description copied from class:ObjectIdGeneratorReturns the scope class used to determine ID uniqueness boundaries. 返回用于确定 ID 唯一性边界的作用域类。- Specified by:
getScopein classObjectIdGenerator<String>- Returns:
- the scope class - 作用域类
-
canUseFor
Description copied from class:ObjectIdGeneratorDetermines whether this generator can be used interchangeably with another. 确定此生成器是否可以与另一个互换使用。- Specified by:
canUseForin classObjectIdGenerator<String>- Parameters:
gen- the other generator to check compatibility with - 要检查兼容性的另一个生成器- Returns:
- true if compatible - 如果兼容则返回 true
-