Interface IdGenerator

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface IdGenerator
ID Generator Interface - Contract for unique ID generation ID 生成器接口 - 唯一 ID 生成契约

Functional interface for implementing custom ID generation strategies.

用于实现自定义 ID 生成策略的函数式接口。

Features | 主要功能:

  • Generate single ID (nextId) - 生成单个 ID
  • Generate multiple IDs (nextIds) - 批量生成 ID
  • Lambda-compatible functional interface - Lambda 兼容的函数式接口

Usage Examples | 使用示例:

// Custom implementation - 自定义实现
IdGenerator generator = () -> UUID.randomUUID().toString();
String id = generator.nextId();
String[] ids = generator.nextIds(10);

Security | 安全性:

  • Thread-safe: Depends on implementation - 线程安全: 取决于实现
  • Null-safe: Implementation dependent - 空值安全: 取决于实现
Since:
JDK 25, opencode-base-core V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Generates the next ID 生成下一个 ID
    default String[]
    nextIds(int count)
    Generates the specified number of IDs 生成指定数量的 ID
  • Method Details

    • nextId

      String nextId()
      Generates the next ID 生成下一个 ID
    • nextIds

      default String[] nextIds(int count)
      Generates the specified number of IDs 生成指定数量的 ID