Record Class PageResult

java.lang.Object
java.lang.Record
org.gcube.informationsystem.resourceregistry.pep.PageResult
Record Components:
json - serialized JSON array for the current page
limit - effective page size (>= 1)
offset - zero-based start index (>= 0)
hasNext - whether a further page exists beyond this one

public record PageResult(String json, int limit, int offset, boolean hasNext) extends Record
Carries a single page of serialized JSON results together with the pagination context needed by the REST layer to emit Link headers.
  • json — the serialized JSON array for the current page (at most limit items)
  • limit — the effective page size used for this request
  • offset — the zero-based start index of this page
  • hasNext — whether a further page exists beyond this one

hasNext must be computed by the caller from the pre-truncation fetch size (e.g. the "peek +1" strategy: fetch limit + 1 items, hasNext = fetched.size() > limit, then truncate to limit before building this record). It must not be re-derived from json.size() == limit, since a last page that happens to be exactly limit items long is indistinguishable from a full intermediate page under that heuristic.

Author:
Luca Frosini (ISTI - CNR)
  • Constructor Summary

    Constructors
    Constructor
    Description
    PageResult(String json, int limit, int offset, boolean hasNext)
    Creates an instance of a PageResult record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the hasNext record component.
    Returns the value of the json record component.
    int
    Returns the value of the limit record component.
    int
    Returns the value of the offset record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

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

    • PageResult

      public PageResult(String json, int limit, int offset, boolean hasNext)
      Creates an instance of a PageResult record class.
      Parameters:
      json - the value for the json record component
      limit - the value for the limit record component
      offset - the value for the offset record component
      hasNext - the value for the hasNext record component
  • Method Details

    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components 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.
    • json

      public String json()
      Returns the value of the json record component.
      Returns:
      the value of the json record component
    • limit

      public int limit()
      Returns the value of the limit record component.
      Returns:
      the value of the limit record component
    • offset

      public int offset()
      Returns the value of the offset record component.
      Returns:
      the value of the offset record component
    • hasNext

      public boolean hasNext()
      Returns the value of the hasNext record component.
      Returns:
      the value of the hasNext record component