Interface CursorStrategy<P>

Type Parameters:
P - the type of position
All Known Implementing Classes:
EncodingCursorStrategy, JsonKeysetCursorStrategy, ScrollPositionCursorStrategy

public interface CursorStrategy<P>
Strategy to convert an Object that represents the position of an item within a paginated result set to and from a String cursor.

A CursorEncoder may be combined with a CursorEncoder via withEncoder(CursorStrategy, CursorEncoder) to further encode and decode cursor Strings to make them opaque for clients.

Since:
1.2.0
Author:
Rossen Stoyanchev
  • Method Summary

    Modifier and Type
    Method
    Description
    Parse the given String cursor into a position Object.
    boolean
    supports(Class<?> targetType)
    Whether the strategy supports the given type of position Object.
    toCursor(P position)
    Format the given position Object as a String cursor.
    static <T> EncodingCursorStrategy<T>
    withEncoder(CursorStrategy<T> strategy, CursorEncoder encoder)
    Decorate the given CursorStrategy with encoding and decoding that makes the String cursor opaque to clients.
  • Method Details

    • supports

      boolean supports(Class<?> targetType)
      Whether the strategy supports the given type of position Object.
      Parameters:
      targetType - the type of position to be checked
    • toCursor

      String toCursor(P position)
      Format the given position Object as a String cursor.
      Parameters:
      position - the position to serialize
      Returns:
      the created String cursor
    • fromCursor

      P fromCursor(String cursor)
      Parse the given String cursor into a position Object.
      Parameters:
      cursor - the cursor to parse
      Returns:
      the position Object
    • withEncoder

      static <T> EncodingCursorStrategy<T> withEncoder(CursorStrategy<T> strategy, CursorEncoder encoder)
      Decorate the given CursorStrategy with encoding and decoding that makes the String cursor opaque to clients.
      Type Parameters:
      T - the type of position for the given strategy
      Parameters:
      strategy - the cursor strategy to decorate
      encoder - strategy for encoding the cursor