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
ConstructorsConstructorDescriptionParsedTsid(String tsidStr, long tsid, Instant time, long timestampMillis, long random) Creates an instance of aParsedTsidrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.Gets the random part as binary string 获取随机部分的二进制字符串longCalculates the approximate sequence number within the millisecond 计算毫秒内的近似序列号Gets the timestamp part as binary string 获取时间戳部分的二进制字符串final inthashCode()Returns a hash code value for this object.longrandom()Returns the value of therandomrecord component.time()Returns the value of thetimerecord component.longReturns the value of thetimestampMillisrecord component.toString()Returns a string representation of this record class.longtsid()Returns the value of thetsidrecord component.tsidStr()Returns the value of thetsidStrrecord component.
-
Constructor Details
-
ParsedTsid
Creates an instance of aParsedTsidrecord class.- Parameters:
tsidStr- the value for thetsidStrrecord componenttsid- the value for thetsidrecord componenttime- the value for thetimerecord componenttimestampMillis- the value for thetimestampMillisrecord componentrandom- the value for therandomrecord component
-
-
Method Details
-
getTimestampBinary
Gets the timestamp part as binary string 获取时间戳部分的二进制字符串- Returns:
- 42-bit binary string | 42位二进制字符串
-
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
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
tsidStr
-
tsid
-
time
-
timestampMillis
public long timestampMillis()Returns the value of thetimestampMillisrecord component.- Returns:
- the value of the
timestampMillisrecord component
-
random
-