Interface IdParser<T,R>

Type Parameters:
T - the type of ID to parse | 要解析的ID类型
R - the type of parse result | 解析结果类型
All Known Implementing Classes:
KsuidParser, SnowflakeIdParser, TsidParser, UlidParser, UuidParser

public interface IdParser<T,R>
ID Parser Interface ID解析器接口

Interface for parsing IDs to extract embedded information such as timestamps, node IDs, and sequence numbers.

用于解析ID以提取嵌入信息(如时间戳、节点ID和序列号)的接口。

Features | 主要功能:

  • Parse ID to structured result - 解析ID为结构化结果
  • Extract timestamp - 提取时间戳
  • Validate ID format - 验证ID格式

Usage Examples | 使用示例:

SnowflakeIdParser parser = SnowflakeIdParser.createDefault();
var parsed = parser.parse(123456789L);
Instant time = parser.extractTimestamp(123456789L);
boolean valid = parser.isValid(123456789L);

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 Type
    Method
    Description
    Extracts the timestamp from an ID 从ID中提取时间戳
    boolean
    isValid(T id)
    Validates the ID format 验证ID格式
    parse(T id)
    Parses an ID to extract embedded information 解析ID以提取嵌入信息
  • Method Details

    • parse

      R parse(T id)
      Parses an ID to extract embedded information 解析ID以提取嵌入信息
      Parameters:
      id - the ID to parse | 要解析的ID
      Returns:
      parse result | 解析结果
    • extractTimestamp

      Instant extractTimestamp(T id)
      Extracts the timestamp from an ID 从ID中提取时间戳
      Parameters:
      id - the ID | ID
      Returns:
      timestamp | 时间戳
    • isValid

      boolean isValid(T id)
      Validates the ID format 验证ID格式
      Parameters:
      id - the ID to validate | 要验证的ID
      Returns:
      true if valid | 如果有效返回true