com.vaadin.signals.

Record Class Id

java.lang.Object
java.lang.Record
com.vaadin.signals.Id

Record Components:

value - the id value as a 64-bit integer

All Implemented Interfaces:

Comparable<Id>

public record Id(long value) extends Record implements Comparable<Id>

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
    Modifier and Type
    Field
    Description
    static final Id

    Id representing the edge of a list.

    static final Id

    Special id value reserved for internal bookkeeping.

    static final Id

    Default or initial id in various contexts.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Id(long value)

    Creates an instance of a Id record class.

  • Method Summary

    Modifier and Type
    Method
    Description
    final String

    Returns this id value as a base64 string.

    int
    compareTo(Id other)
     
    final boolean

    Indicates whether some other object is "equal to" this one.

    final int

    Returns a hash code value for this object.

    static Id
    parse(String base64)

    Parses the given base64 string as an id.

    static Id

    Creates a random id.

    final String

    Returns a string representation of this record class.

    long

    Returns the value of the value record component.

    Methods inherited from class java.lang.Object

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

    • ZERO

      public static final Id 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

      public static final Id 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

      public static final Id 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 the value record component

  • Method Details

    • random

      public static Id 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

      public static Id parse(String base64)

      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, not null

      Returns:

      the parsed id.

    • asBase64

      public final String asBase64()

      Returns this id value as a base64 string.

      Returns:

      the base64 string representing this id

    • compareTo

      public int compareTo(Id other)

      Specified by:

      compareTo in interface Comparable<Id>

    • toString

      public final 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. All components in this record class are compared with '=='.

      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.

    • value

      public long value()

      Returns the value of the value record component.

      Returns:

      the value of the value record component