Package su.onno.query
Record Class Cursor
java.lang.Object
java.lang.Record
su.onno.query.Cursor
- Record Components:
column- the sort column this cursor was minted for (validated against the entity)descending- the sort direction it was minted forvalue- the sort column's value on the cursor row, ornull(NULLS-LAST tail)id- the_idtiebreaker of the cursor row
An opaque, self-describing position in a keyset-paginated list — the "where I left off" token a
client echoes back to fetch the next window. It captures the last row of a page as the pair the
seek predicate needs: the value of the sort column and the
_id tiebreaker, plus the sort
column + direction it was minted for so a stale cursor (the client changed the sort) can be
detected and ignored rather than silently returning a wrong window.
The wire form is URL-safe Base64 of a tagged, unit-separated record:
v1␟{column}␟{a|d}␟{typeTag}␟{value}␟{uuid}. The value is typed (string, long, decimal,
boolean, timestamp-as-epoch-millis, uuid, or null) so it round-trips back to a JDBI-bindable
object that compares correctly against its column — a date cursor binds as a Timestamp,
not a string. The token is a position, not a credential: every field is re-validated and
the value is always bound as a parameter, so a tampered token can only point at a different row,
never inject SQL.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncolumn()Returns the value of thecolumnrecord component.static CursorDecode a token to a cursor, ornullif it is blank or not a well-formed v1 token.static CursorDecode a token, but only if it still matches the active sort — a cursor minted for a different column or direction (the client re-sorted) is treated as absent so paging restarts cleanly from the first window.booleanReturns the value of thedescendingrecord component.encode()The URL-safe token to hand back to the client asnextCursor.final booleanIndicates whether some other object is "equal to" this one.static CursorBuild the cursor that points atrowas the last row of the current page.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.final StringtoString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.
-
Constructor Details
-
Cursor
Creates an instance of aCursorrecord class.- Parameters:
column- the value for thecolumnrecord componentdescending- the value for thedescendingrecord componentvalue- the value for thevaluerecord componentid- the value for theidrecord component
-
-
Method Details
-
from
Build the cursor that points atrowas the last row of the current page. -
decodeFor
Decode a token, but only if it still matches the active sort — a cursor minted for a different column or direction (the client re-sorted) is treated as absent so paging restarts cleanly from the first window. A blank or malformed token likewise yieldsnull. -
decode
Decode a token to a cursor, ornullif it is blank or not a well-formed v1 token. -
encode
The URL-safe token to hand back to the client asnextCursor. -
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
column
Returns the value of thecolumnrecord component.- Returns:
- the value of the
columnrecord component
-
descending
public boolean descending()Returns the value of thedescendingrecord component.- Returns:
- the value of the
descendingrecord component
-
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-