Record Class TsidParser.ParsedTsid

java.lang.Object
java.lang.Record
cloud.opencode.base.id.tsid.TsidParser.ParsedTsid
Record Components:
tsidStr - the TSID as string (13 characters) | TSID字符串(13字符)
tsid - the TSID as long value | TSID长整型值
time - the timestamp as Instant | 时间戳(Instant)
timestampMillis - the timestamp in milliseconds | 时间戳(毫秒)
random - the random/counter component (22 bits) | 随机/计数器组件(22位)
Enclosing class:
TsidParser

public static record TsidParser.ParsedTsid(String tsidStr, long tsid, Instant time, long timestampMillis, long random) extends Record
Parsed TSID Result 解析的TSID结果
Since:
JDK 25, opencode-base-id V1.4.0
Author:
Leon Soo www.LeonSoo.com
  • Constructor Summary

    Constructors
    Constructor
    Description
    ParsedTsid(String tsidStr, long tsid, Instant time, long timestampMillis, long random)
    Creates an instance of a ParsedTsid record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    Gets the random part as binary string 获取随机部分的二进制字符串
    long
    Calculates the approximate sequence number within the millisecond 计算毫秒内的近似序列号
    Gets the timestamp part as binary string 获取时间戳部分的二进制字符串
    final int
    Returns a hash code value for this object.
    long
    Returns the value of the random record component.
    Returns the value of the time record component.
    long
    Returns the value of the timestampMillis record component.
    Returns a string representation of this record class.
    long
    Returns the value of the tsid record component.
    Returns the value of the tsidStr record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ParsedTsid

      public ParsedTsid(String tsidStr, long tsid, Instant time, long timestampMillis, long random)
      Creates an instance of a ParsedTsid record class.
      Parameters:
      tsidStr - the value for the tsidStr record component
      tsid - the value for the tsid record component
      time - the value for the time record component
      timestampMillis - the value for the timestampMillis record component
      random - the value for the random record component
  • Method Details

    • getTimestampBinary

      public String getTimestampBinary()
      Gets the timestamp part as binary string 获取时间戳部分的二进制字符串
      Returns:
      42-bit binary string | 42位二进制字符串
    • getRandomBinary

      public String getRandomBinary()
      Gets the random part as binary string 获取随机部分的二进制字符串
      Returns:
      22-bit binary string | 22位二进制字符串
    • getSequence

      public long getSequence()
      Calculates the approximate sequence number within the millisecond 计算毫秒内的近似序列号

      Note: This is only accurate if the TSID was generated with counter mode, not purely random mode.

      注意:仅当TSID使用计数器模式生成时才准确,纯随机模式不准确。

      Returns:
      random/counter value | 随机/计数器值
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • tsidStr

      public String tsidStr()
      Returns the value of the tsidStr record component.
      Returns:
      the value of the tsidStr record component
    • tsid

      public long tsid()
      Returns the value of the tsid record component.
      Returns:
      the value of the tsid record component
    • time

      public Instant time()
      Returns the value of the time record component.
      Returns:
      the value of the time record component
    • timestampMillis

      public long timestampMillis()
      Returns the value of the timestampMillis record component.
      Returns:
      the value of the timestampMillis record component
    • random

      public long random()
      Returns the value of the random record component.
      Returns:
      the value of the random record component