com.vaadin.signals.
Record Class Id
Record Components:
value
- the id value as a 64-bit integer
All Implemented Interfaces:
Generated identifier for signals and other related resources.
The id is a random 64-bit number to be more compact than a full 128-bit UUID
or such. The ids don't need to be globally unique but only unique within a
smaller context so the risk of collisions is still negligible. The value is
JSON serialized as a base64-encoded string with a special case,
""
, for the frequently used special 0 id. The ids are comparable
to facilitate consistent ordering to avoid deadlocks in certain situations.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal String
asBase64()
Returns this id value as a base64 string.
int
final boolean
Indicates whether some other object is "equal to" this one.
final int
hashCode()
Returns a hash code value for this object.
static Id
Parses the given base64 string as an id.
static Id
random()
Creates a random id.
final String
toString()
Returns a string representation of this record class.
long
value()
Returns the value of the
value
record component.
-
Field Details
-
ZERO
Default or initial id in various contexts. Always used for the root node in a signal hierarchy. The zero id is frequently used and has a custom compact JSON representation.
-
EDGE
Id representing the edge of a list. This can be either the position immediately before the first entry or the position immediately after the last entry.
-
MAX
Special id value reserved for internal bookkeeping.
-
-
Constructor Details
-
Id
public Id(long value) Creates an instance of a
Id
record class.Parameters:
value
- the value for thevalue
record component
-
-
Method Details
-
random
Creates a random id. Randomness is only needed to reduce the risk of collisions but there's no security impact from being able to guess random ids.
Returns:
a random id, not
null
-
parse
Parses the given base64 string as an id. As a special case, the empty string is parsed as
ZERO
.Parameters:
base64
- the base64 string to parse, notnull
Returns:
the parsed id.
-
asBase64
Returns this id value as a base64 string.
Returns:
the base64 string representing this id
-
compareTo
Specified by:
compareTo
in interfaceComparable<Id>
-
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 the
value
record component.Returns:
the value of the
value
record component
-