Package org.cyclos.utils
Class PageImpl<T>
- java.lang.Object
-
- org.cyclos.utils.PageImpl<T>
-
- Type Parameters:
T- The data type
- All Implemented Interfaces:
Serializable,Iterable<T>,HasPartialData,Page<T>
public class PageImpl<T> extends Object implements Page<T>, Serializable
An implementation for aPage- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.cyclos.utils.Page
CURRENT_PAGE, DEFAULT_PAGE_SIZE, HAS_NEXT_PAGE, PAGE_COUNT, PAGE_ITEMS, PAGE_SIZE, PARTIAL_DATA, TOTAL_COUNT
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPageImpl()PageImpl(List<T> pageItems, int pageSize, int currentPage, Integer totalCount, boolean hasNextPage)PageImpl(List<T> pageItems, int pageSize, int currentPage, Integer totalCount, boolean hasNextPage, boolean partialData)PageImpl(Page<T> copy)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> Page<T>empty()static <T> Page<T>empty(int pageSize, int currentPage)intgetCurrentPage()Returns the number of this page within the totalIntegergetPageCount()Returns the total number of pages.List<T>getPageItems()Returns the page itemsintgetPageSize()Returns the page sizeIntegergetTotalCount()Returns the total number of records.booleanisHasNextPage()Returns whether a next page existsbooleanisPartialData()Indicates whether only part of the expected data is being returned due to a failure in the backend service (such failing OpenSearch shards).Iterator<T>iterator()static <I,T>
Page<T>page(T result)voidsetCurrentPage(int currentPage)voidsetHasNextPage(boolean hasNextPage)voidsetPageItems(List<T> pageItems)voidsetPageSize(int pageSize)voidsetPartialData(boolean partialData)voidsetTotalCount(Integer totalCount)Stream<T>stream()Returns a stream with the page itemsStringtoString()static <I,T>
Page<T>transformed(Page<I> original, Function<? super I,T> transformer)static <T> Page<T>withNextPage(List<T> pageItems, int pageSize, int currentPage, boolean hasNextPage)static <T> Page<T>withTotalCount(List<T> pageItems, int totalCount, int pageSize, int currentPage)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
PageImpl
public PageImpl(List<T> pageItems, int pageSize, int currentPage, Integer totalCount, boolean hasNextPage)
-
PageImpl
public PageImpl(List<T> pageItems, int pageSize, int currentPage, Integer totalCount, boolean hasNextPage, boolean partialData)
-
PageImpl
protected PageImpl()
-
-
Method Detail
-
empty
public static <T> Page<T> empty()
-
empty
public static <T> Page<T> empty(int pageSize, int currentPage)
-
page
public static <I,T> Page<T> page(T result)
-
transformed
public static <I,T> Page<T> transformed(Page<I> original, Function<? super I,T> transformer)
-
withNextPage
public static <T> Page<T> withNextPage(List<T> pageItems, int pageSize, int currentPage, boolean hasNextPage)
-
withTotalCount
public static <T> Page<T> withTotalCount(List<T> pageItems, int totalCount, int pageSize, int currentPage)
-
getCurrentPage
public int getCurrentPage()
Description copied from interface:PageReturns the number of this page within the total- Specified by:
getCurrentPagein interfacePage<T>
-
getPageCount
public Integer getPageCount()
Description copied from interface:PageReturns the total number of pages. If the total count is unknown, returns null.- Specified by:
getPageCountin interfacePage<T>
-
getPageItems
public List<T> getPageItems()
Description copied from interface:PageReturns the page items- Specified by:
getPageItemsin interfacePage<T>
-
getPageSize
public int getPageSize()
Description copied from interface:PageReturns the page size- Specified by:
getPageSizein interfacePage<T>
-
getTotalCount
public Integer getTotalCount()
Description copied from interface:PageReturns the total number of records. If the total count is unknown, returns null.- Specified by:
getTotalCountin interfacePage<T>
-
isHasNextPage
public boolean isHasNextPage()
Description copied from interface:PageReturns whether a next page exists- Specified by:
isHasNextPagein interfacePage<T>
-
isPartialData
public boolean isPartialData()
Description copied from interface:HasPartialDataIndicates whether only part of the expected data is being returned due to a failure in the backend service (such failing OpenSearch shards).- Specified by:
isPartialDatain interfaceHasPartialData
-
setCurrentPage
public void setCurrentPage(int currentPage)
-
setHasNextPage
public void setHasNextPage(boolean hasNextPage)
-
setPageSize
public void setPageSize(int pageSize)
-
setPartialData
public void setPartialData(boolean partialData)
-
setTotalCount
public void setTotalCount(Integer totalCount)
-
stream
public Stream<T> stream()
Description copied from interface:PageReturns a stream with the page items
-
-