Package org.apache.unomi.api
Class PartialList<T>
java.lang.Object
org.apache.unomi.api.PartialList<T>
- Type Parameters:
T
- the generic type of contained elements
- All Implemented Interfaces:
Serializable
A list of elements representing a limited view of a larger list, starting from a given element (offset from the first) and showing only a given number of elements, instead of
showing all of them. This is useful to retrieve "pages" of large element collections.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
This enum exists to replicate Lucene's total hits relation in a back-end agnostic way. -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a new PartialList.PartialList
(List<T> list, long offset, long pageSize, long totalSize, PartialList.Relation totalSizeRelation) Instantiates a new PartialList. -
Method Summary
Modifier and TypeMethodDescriptionget
(int index) Retrieves the element at the specified indexgetList()
Retrieves the limited list view.long
Retrieves the offset of the first element of the view.long
Retrieves the number of elements this PartialList contains.Retrieve the scroll identifier to make it possible to continue a scrolling list queryRetrieve the value of the scroll time validity to make it possible to continue a scrolling list querylong
Retrieves the total size of elements in the original List.Retrieve the relation to the total site, wether it is equal to or greater than the value stored in the totalSize property.void
Sets the view list.void
setOffset
(long offset) void
setPageSize
(long pageSize) void
setScrollIdentifier
(String scrollIdentifier) void
setScrollTimeValidity
(String scrollTimeValidity) void
setTotalSize
(long totalSize) void
setTotalSizeRelation
(PartialList.Relation totalSizeRelation) int
size()
Retrieves the size of this PartialList.
-
Constructor Details
-
PartialList
public PartialList()Instantiates a new PartialList. -
PartialList
public PartialList(List<T> list, long offset, long pageSize, long totalSize, PartialList.Relation totalSizeRelation) Instantiates a new PartialList.- Parameters:
list
- the limited view into the bigger List this PartialList is representingoffset
- the offset of the first element in the viewpageSize
- the number of elements this PartialList containstotalSize
- the total size of elements in the original ListtotalSizeRelation
- the relation to the total size (equals or greater than)
-
-
Method Details
-
getList
Retrieves the limited list view.- Returns:
- a List of the
size
elements starting from theoffset
-th one from the original, larger list
-
setList
Sets the view list.- Parameters:
list
- the view list into the bigger List this PartialList is representing
-
getOffset
public long getOffset()Retrieves the offset of the first element of the view.- Returns:
- the offset of the first element of the view
-
setOffset
public void setOffset(long offset) -
getPageSize
public long getPageSize()Retrieves the number of elements this PartialList contains.- Returns:
- the number of elements this PartialList contains
-
setPageSize
public void setPageSize(long pageSize) -
getTotalSize
public long getTotalSize()Retrieves the total size of elements in the original List.- Returns:
- the total size of elements in the original List
-
setTotalSize
public void setTotalSize(long totalSize) -
size
public int size()Retrieves the size of this PartialList. Should equalgetPageSize()
.- Returns:
- the size of this PartialList
-
get
Retrieves the element at the specified index- Parameters:
index
- the index of the element to retrieve- Returns:
- the element at the specified index
-
getScrollIdentifier
Retrieve the scroll identifier to make it possible to continue a scrolling list query- Returns:
- a string containing the scroll identifier, to be sent back in an subsequent request
-
setScrollIdentifier
-
getScrollTimeValidity
Retrieve the value of the scroll time validity to make it possible to continue a scrolling list query- Returns:
- a string containing a time value for the scroll validity, to be sent back in a subsequent request
-
setScrollTimeValidity
-
getTotalSizeRelation
Retrieve the relation to the total site, wether it is equal to or greater than the value stored in the totalSize property.- Returns:
- a Relation enum value that describes the type of total size we have in this object.
-
setTotalSizeRelation
-