Class PageResponse<T>

java.lang.Object
overit.geocall.model.PageResponse<T>
Type Parameters:
T - the type of the response's content

public class PageResponse<T> extends Object
Data transfer object containing the results fetched by a query request. The response contains also the information about the pagination (number of the page, if there's more results to load, ...)
Since:
9.0
GCApi:
dto
  • Field Details

  • Constructor Details

    • PageResponse

      public PageResponse(List<T> content, int page, boolean hasMore)
      Create a new response containing a set of results.
      Parameters:
      content - the list containing the object that will be sent with the response
      page - the page's number
      hasMore - if there's more results that can be loaded or not
  • Method Details

    • emptyResponse

      public static <T> PageResponse<T> emptyResponse()
      Utility method to easily create an empty response.
      Type Parameters:
      T - the type of the response's content
      Returns:
      an empty response
    • getContent

      public List<T> getContent()
      Returns the content of the response
      Returns:
      a list containing the response's content
    • getPageNumber

      public int getPageNumber()
      Returns the number of the page. Zero means that the results has not been paginated.
      Returns:
      the page's number
    • hasMorePages

      public boolean hasMorePages()
      Get the indication if there's more results that can be loaded or not.
      Returns:
      true if there's more results that can be loaded, false otherwise
    • getTotal

      public Long getTotal()
      Get the total number of available entries
      Returns:
      the sum of the entry of each page or null if not this info is not available
    • setTotal

      public void setTotal(long total)
      Set the total number of available entries
      Parameters:
      total - the sum of the entry of each page. The value MUST be a positive number
    • mapContent

      public <C> PageResponse<C> mapContent(M2Mapper mapper, Class<C> targetClass)
      Convert the object contained into the response into another type.
      Type Parameters:
      C - the type to convert to
      Parameters:
      mapper - The M2Mapper
      targetClass - the class of the type to convert to
      Returns:
      the response whose content has been converted into the passed type