Class PageResponse<T>
java.lang.Object
de.digitalcollections.model.list.ListResponse<T,PageRequest>
de.digitalcollections.model.list.paging.PageResponse<T>
- Type Parameters:
T
- object type listed in page
- All Implemented Interfaces:
Iterable<T>
- Direct Known Subclasses:
BucketObjectsResponse
Container for pagination information. See Spring Data Commons, but more flat design and
independent of Spring libraries.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
PageResponse.Builder<T,
B extends PageResponse<T>, C extends PageResponse.Builder> -
Field Summary
Fields inherited from class de.digitalcollections.model.list.ListResponse
content, executedSearchTerm, request, total
-
Constructor Summary
ConstructorsConstructorDescriptionPageResponse
(List<T> content) Creates a newPageResponse
with the given content.PageResponse
(List<T> content, PageRequest request, long total) Constructor ofPageResponse
with the given content and the given governingPageRequest
.PageResponse
(List<T> content, PageRequest request, long total, String executedSearchTerm) Constructor ofPageResponse
with the given content and the given governingPageRequest
. -
Method Summary
Modifier and TypeMethodDescriptionstatic PageResponse.Builder
builder()
static PageResponse.Builder
boolean
getNavItems
(int maxNumberOfItems) Utility method for creating a paging navigation.int
Returns the number of elements currently on thisPageResponse
.int
Returns the number of the currentPageResponse
.int
getSize()
Returns the size of thePageResponse
.int
Returns the number of total pages.boolean
hasNext()
Returns if there is a nextPageResponse
.boolean
Returns if there is a previousPageResponse
.protected void
init()
boolean
isFirst()
Returns whether the currentPageResponse
is the first one.boolean
isLast()
Returns whether the currentPageResponse
is the last one.Returns thePageRequest
to request the nextPageResponse
.Returns thePageRequest
to request the previousPageResponse
.toString()
Methods inherited from class de.digitalcollections.model.list.ListResponse
getContent, getExecutedSearchTerm, getRequest, getSorting, getTotalElements, hasContent, hashCode, iterator, setContent, setExecutedSearchTerm, setRequest, setTotalElements
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
PageResponse
public PageResponse() -
PageResponse
Creates a newPageResponse
with the given content. This will result in the createdPageResponse
being identical to the entireList
.- Parameters:
content
- must not be null.
-
PageResponse
Constructor ofPageResponse
with the given content and the given governingPageRequest
.- Parameters:
content
- the content of this page, must not be null.request
- the paging information, can be null.total
- the total amount of items available. The total might be adapted considering the length of the content given, if it is going to be the content of the last page. This is in place to mitigate inconsistencies
-
PageResponse
Constructor ofPageResponse
with the given content and the given governingPageRequest
.- Parameters:
content
- the content of this page, must not be null.request
- the paging information, can be null.total
- the total amount of items available. The total might be adapted considering the length of the content given, if it is going to be the content of the last page. This is in place to mitigate inconsistenciesexecutedSearchTerm
- search term being effectively used (may bechanged/normalized in comparance to original sent request search term) on server side for some reason
-
-
Method Details
-
builder
-
builder
-
equals
- Overrides:
equals
in classListResponse<T,
PageRequest>
-
getNumberOfElements
public int getNumberOfElements()Returns the number of elements currently on thisPageResponse
.- Returns:
- the number of elements currently on this
PageResponse
.
-
getPageNumber
public int getPageNumber()Returns the number of the currentPageResponse
. Is always non-negative.- Returns:
- the number of the current
PageResponse
.
-
getSize
public int getSize()Returns the size of thePageResponse
.- Returns:
- the size of the
PageResponse
.
-
getTotalPages
public int getTotalPages()Returns the number of total pages.- Returns:
- the number of total pages
-
hasNext
public boolean hasNext()Returns if there is a nextPageResponse
.- Returns:
- if there is a next
PageResponse
.
-
hasPrevious
public boolean hasPrevious()Returns if there is a previousPageResponse
.- Returns:
- if there is a previous
PageResponse
.
-
init
protected void init()- Overrides:
init
in classListResponse<T,
PageRequest>
-
isFirst
public boolean isFirst()Returns whether the currentPageResponse
is the first one.- Returns:
- whether the current
PageResponse
is the first one.
-
isLast
public boolean isLast()Returns whether the currentPageResponse
is the last one.- Returns:
- whether the current
PageResponse
is the last one.
-
nextPageRequest
Returns thePageRequest
to request the nextPageResponse
. Can be null in case the currentPageResponse
is already the last one. Clients should checkhasNext()
before calling this method to make sure they receive a non-null value.- Returns:
- the
PageRequest
to request the nextPageResponse
-
previousPageRequest
Returns thePageRequest
to request the previousPageResponse
. Can be null in case the currentPageResponse
is already the first one. Clients should checkhasPrevious()
before calling this method make sure receive a non-null value.- Returns:
- the
PageRequest
to request the previousPageResponse
-
toString
- Overrides:
toString
in classListResponse<T,
PageRequest>
-