Class PageResponseImpl<T>
- java.lang.Object
-
- de.digitalcollections.model.impl.paging.PageResponseImpl<T>
-
- All Implemented Interfaces:
PageResponse<T>,Iterable<T>
public class PageResponseImpl<T> extends Object implements PageResponse<T>
-
-
Constructor Summary
Constructors Constructor Description PageResponseImpl()PageResponseImpl(List<T> content)Creates a newPageResponseImplwith the given content.PageResponseImpl(List<T> content, PageRequest pageRequest, long total)Constructor ofPageResponseImplwith the given content and the given governingPageRequest.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)List<T>getContent()intgetNumber()Returns the number of the currentPageResponse.intgetNumberOfElements()Returns the number of elements currently on thisPageResponse.PageRequestgetPageRequest()intgetSize()Returns the size of thePageResponse.SortinggetSorting()longgetTotalElements()Returns the total amount of elements.intgetTotalPages()Returns the number of total pages.booleanhasContent()Returns whether thePageResponsehas content at all.inthashCode()booleanhasNext()Returns if there is a nextPageResponse.booleanhasPrevious()Returns if there is a previousPageResponse.booleanisFirst()Returns whether the currentPageResponseis the first one.booleanisLast()Returns whether the currentPageResponseis the last one.Iterator<T>iterator()PageRequestnextPageRequest()Returns thePageRequestto request the nextPageResponse.PageRequestpreviousPageRequest()Returns thePageRequestto request the previousPageResponse.voidsetContent(List<T> content)Allows to set the content (needed in case of content has to be converted/casted)voidsetPageRequest(PageRequest pageRequest)voidsetTotalElements(long totalElements)StringtoString()-
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 Detail
-
PageResponseImpl
public PageResponseImpl()
-
PageResponseImpl
public PageResponseImpl(List<T> content, PageRequest pageRequest, long total)
Constructor ofPageResponseImplwith the given content and the given governingPageRequest.- Parameters:
content- the content of this page, must not be null.pageRequest- 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
-
PageResponseImpl
public PageResponseImpl(List<T> content)
Creates a newPageResponseImplwith the given content. This will result in the createdPageResponsebeing identical to the entireList.- Parameters:
content- must not be null.
-
-
Method Detail
-
getContent
public List<T> getContent()
- Specified by:
getContentin interfacePageResponse<T>- Returns:
- the page content/objects as
List.
-
setContent
public void setContent(List<T> content)
Description copied from interface:PageResponseAllows to set the content (needed in case of content has to be converted/casted)- Specified by:
setContentin interfacePageResponse<T>- Parameters:
content- list of content/objects of this page
-
getNumber
public int getNumber()
Description copied from interface:PageResponseReturns the number of the currentPageResponse. Is always non-negative.- Specified by:
getNumberin interfacePageResponse<T>- Returns:
- the number of the current
PageResponse.
-
getNumberOfElements
public int getNumberOfElements()
Description copied from interface:PageResponseReturns the number of elements currently on thisPageResponse.- Specified by:
getNumberOfElementsin interfacePageResponse<T>- Returns:
- the number of elements currently on this
PageResponse.
-
getPageRequest
public PageRequest getPageRequest()
- Specified by:
getPageRequestin interfacePageResponse<T>- Returns:
- the PageRequest used to get this PageResponse
-
setPageRequest
public void setPageRequest(PageRequest pageRequest)
-
getSize
public int getSize()
Description copied from interface:PageResponseReturns the size of thePageResponse.- Specified by:
getSizein interfacePageResponse<T>- Returns:
- the size of the
PageResponse.
-
getSorting
public Sorting getSorting()
- Specified by:
getSortingin interfacePageResponse<T>- Returns:
- the sorting parameters for the
PageResponse.
-
getTotalElements
public long getTotalElements()
Description copied from interface:PageResponseReturns the total amount of elements.- Specified by:
getTotalElementsin interfacePageResponse<T>- Returns:
- the total amount of elements
-
setTotalElements
public void setTotalElements(long totalElements)
-
getTotalPages
public int getTotalPages()
Description copied from interface:PageResponseReturns the number of total pages.- Specified by:
getTotalPagesin interfacePageResponse<T>- Returns:
- the number of total pages
-
hasContent
public boolean hasContent()
Description copied from interface:PageResponseReturns whether thePageResponsehas content at all.- Specified by:
hasContentin interfacePageResponse<T>- Returns:
- whether the
PageResponsehas content at all.
-
hasNext
public boolean hasNext()
Description copied from interface:PageResponseReturns if there is a nextPageResponse.- Specified by:
hasNextin interfacePageResponse<T>- Returns:
- if there is a next
PageResponse.
-
hasPrevious
public boolean hasPrevious()
Description copied from interface:PageResponseReturns if there is a previousPageResponse.- Specified by:
hasPreviousin interfacePageResponse<T>- Returns:
- if there is a previous
PageResponse.
-
isFirst
public boolean isFirst()
Description copied from interface:PageResponseReturns whether the currentPageResponseis the first one.- Specified by:
isFirstin interfacePageResponse<T>- Returns:
- whether the current
PageResponseis the first one.
-
isLast
public boolean isLast()
Description copied from interface:PageResponseReturns whether the currentPageResponseis the last one.- Specified by:
isLastin interfacePageResponse<T>- Returns:
- whether the current
PageResponseis the last one.
-
nextPageRequest
public PageRequest nextPageRequest()
Description copied from interface:PageResponseReturns thePageRequestto request the nextPageResponse. Can be null in case the currentPageResponseis already the last one. Clients should checkPageResponse.hasNext()before calling this method to make sure they receive a non-null value.- Specified by:
nextPageRequestin interfacePageResponse<T>- Returns:
- the
PageRequestto request the nextPageResponse
-
previousPageRequest
public PageRequest previousPageRequest()
Description copied from interface:PageResponseReturns thePageRequestto request the previousPageResponse. Can be null in case the currentPageResponseis already the first one. Clients should checkPageResponse.hasPrevious()before calling this method make sure receive a non-null value.- Specified by:
previousPageRequestin interfacePageResponse<T>- Returns:
- the
PageRequestto request the previousPageResponse
-
-