Class ListResponse<T>
- java.lang.Object
-
- com.sinch.sdk.core.models.pagination.ListResponse<T>
-
- Direct Known Subclasses:
ActiveNumberListResponse,AvailableNumberListResponse,AvailableRegionListResponse,BatchesListResponse,DeliveryReportsListResponse,GroupsListResponse,InboundsListResponse
public abstract class ListResponse<T> extends Object
Abstract class used for handling unified paginated responseAct as an iterator over pages response and pages content.
- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description ListResponse()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Collection<T>getContent()Get the page items collection contentabstract booleanhasNextPage()Indicate if another page response is availableIterator<T>iterator()Get an iterator across all items available across all page responsesabstract ListResponse<T>nextPage()Get next page response if availableStream<T>stream()Getting a stream across all items
-
-
-
Method Detail
-
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 responsesUnderline 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
-
-