Package overit.geocall.model
Class PageResponse<T>
java.lang.Object
overit.geocall.model.PageResponse<T>
- Type Parameters:
T- the type of the response's content
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPageResponse(List<T> content, int page, boolean hasMore) Create a new response containing a set of results. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> PageResponse<T> Utility method to easily create an empty response.Returns the content of the responseintReturns the number of the page.getTotal()Get the total number of available entriesbooleanGet the indication if there's more results that can be loaded or not.<C> PageResponse<C> mapContent(M2Mapper mapper, Class<C> targetClass) Convert the object contained into the response into another type.voidsetTotal(long total) Set the total number of available entries
-
Field Details
-
-
page
-
-
Constructor Details
-
PageResponse
Create a new response containing a set of results.- Parameters:
content- the list containing the object that will be sent with the responsepage- the page's numberhasMore- if there's more results that can be loaded or not
-
-
Method Details
-
emptyResponse
Utility method to easily create an empty response.- Type Parameters:
T- the type of the response's content- Returns:
- an empty response
-
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:
trueif there's more results that can be loaded,falseotherwise
-
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
Convert the object contained into the response into another type.- Type Parameters:
C- the type to convert to- Parameters:
mapper- The M2MappertargetClass- the class of the type to convert to- Returns:
- the response whose content has been converted into the passed type
-