Class ListResponse<T>

java.lang.Object
com.sinch.sdk.core.models.pagination.ListResponse<T>
Type Parameters:
T - Page content items type
Direct Known Subclasses:
ActiveNumberListResponse, AvailableNumberListResponse, AvailableRegionListResponse, BatchesListResponse, DeliveryReportsListResponse, GroupsListResponse, InboundsListResponse

public abstract class ListResponse<T> extends Object
Abstract class used for handling unified paginated response

Act as an iterator over pages response and pages content.

Since:
1.0
  • Method Details

    • hasNextPage

      public abstract boolean hasNextPage()
      Indicate if another page response is available
      Returns:
      Returns true if the iteration has more pages. (In other words, returns true if next() would return a page rather than throwing an exception.)
    • nextPage

      public abstract ListResponse<T> nextPage() throws NoSuchElementException
      Get next page response if available
      Returns:
      Returns the next page in the pagination/iteration. Next page response. Exception is throw in case no page available; call hasNextPage before to ensure is page is available
      Throws:
      NoSuchElementException - if the iteration has no more pages
    • getContent

      public abstract Collection<T> getContent()
      Get the page items collection content
      Returns:
      The items related to current page content
    • iterator

      public Iterator<T> iterator()
      Get an iterator across all items available across all page responses

      Underline API (HTTP request) will be called on demand when next page content will be required to fulfill iterator with items for consecutive page

      Returns:
      Iterator onto items
    • stream

      public Stream<T> stream()
      Getting a stream across all items

      Underline API (HTTP request) will be called on demand when next page content will be required to fulfill iterator with items for consecutive page

      Returns:
      Stream onto items