Package com.fayupable.snowflake
Record Class SnowflakeId
java.lang.Object
java.lang.Record
com.fayupable.snowflake.SnowflakeId
Value object representing a generated Snowflake id decomposed into its parts.
Use fromLong to parse an existing id back into timestamp, node and sequence components.
-
Constructor Summary
ConstructorsConstructorDescriptionSnowflakeId(long value, long timestamp, long nodeId, long sequence) Creates an instance of aSnowflakeIdrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static SnowflakeIdfromLong(long id, SnowflakeConfig config) final inthashCode()Returns a hash code value for this object.longnodeId()Returns the value of thenodeIdrecord component.longsequence()Returns the value of thesequencerecord component.longReturns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.longvalue()Returns the value of thevaluerecord component.
-
Constructor Details
-
SnowflakeId
public SnowflakeId(long value, long timestamp, long nodeId, long sequence) Creates an instance of aSnowflakeIdrecord class.- Parameters:
value- the value for thevaluerecord componenttimestamp- the value for thetimestamprecord componentnodeId- the value for thenodeIdrecord componentsequence- the value for thesequencerecord component
-
-
Method Details
-
fromLong
-
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. -
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. -
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. All components in this record class are compared with '=='. -
value
public long value()Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-
timestamp
public long timestamp()Returns the value of thetimestamprecord component.- Returns:
- the value of the
timestamprecord component
-
nodeId
public long nodeId()Returns the value of thenodeIdrecord component.- Returns:
- the value of the
nodeIdrecord component
-
sequence
public long sequence()Returns the value of thesequencerecord component.- Returns:
- the value of the
sequencerecord component
-