Record Class PageToken

java.lang.Object
java.lang.Record
org.a2aproject.sdk.util.PageToken
Record Components:
timestamp - The timestamp component of the page token
id - The identifier component of the page token

public record PageToken(Instant timestamp, String id) extends Record
Represents a pagination token for keyset-based pagination.

PageTokens use the format "timestamp_millis:id" where:

  • timestamp_millis - Unix timestamp in milliseconds (numeric)
  • id - The entity identifier (String)
This format enables efficient keyset pagination by allowing queries to resume at a specific point in a timestamp-sorted, ID-secondary-sorted result set.
  • Constructor Details

    • PageToken

      public PageToken(Instant timestamp, String id)
      Creates an instance of a PageToken record class.
      Parameters:
      timestamp - the value for the timestamp record component
      id - the value for the id record component
  • Method Details

    • fromString

      public static @Nullable PageToken fromString(@Nullable String tokenStr)
      Parses a pageToken string into a PageToken record.

      Expected format: "timestamp_millis:id"

      Parameters:
      tokenStr - The pageToken string to parse, may be null or empty
      Returns:
      A PageToken instance, or null if tokenStr is null or empty
      Throws:
      InvalidParamsError - if the token format is invalid or timestamp is not numeric
    • toString

      public String toString()
      Converts this PageToken to its string representation.

      Format: "timestamp_millis:id"

      Specified by:
      toString in class Record
      Returns:
      The pageToken string
    • 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 Objects::equals(Object,Object).
      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.
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp record component
    • id

      public String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component