Interface PageToken

All Known Implementing Classes:
EmptyPageToken, FallbackPageToken

public interface PageToken
Encodes search result pages into reasonably compact page tokens, and decodes them back into listing requests.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final PageToken
    "Empty" page token that allows to have only one page of results.
  • Method Summary

    Modifier and Type
    Method
    Description
    decode(ListRequest.Builder<T> bldr, @NonNull String token)
    Decodes page token into listing request.
    This method must be called only once per page, because it changes the listing request builder's state and is therefore non-idempotent.
    <T, R> String
    encode(@NonNull GenericListResult<T,R> result)
    Encodes information about next search result page.
  • Field Details

    • EMPTY

      static final PageToken EMPTY
      "Empty" page token that allows to have only one page of results. Its encode() always returns null, and decode() always fails.
  • Method Details

    • encode

      @Nullable <T, R> String encode(@NonNull @NonNull GenericListResult<T,R> result)
      Encodes information about next search result page.
      Type Parameters:
      T - search request type
      R - search result type
      Parameters:
      result - current search result page
      Returns:
      next page token or null if this is the last page of results
    • decode

      @NonNull <T> ListRequest.Builder<T> decode(@NonNull ListRequest.Builder<T> bldr, @NonNull @NonNull String token) throws BadListingException.InvalidPageToken
      Decodes page token into listing request.
      This method must be called only once per page, because it changes the listing request builder's state and is therefore non-idempotent.
      Type Parameters:
      T - search request type
      Parameters:
      bldr - listing request builder
      token - page token
      Returns:
      listing request builder for to the page encoded by the token
      Throws:
      BadListingException.InvalidPageToken - page token is invalid