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
public class PartialList<T> extends Object implements 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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPartialList.RelationThis enum exists to replicate Lucene's total hits relation in a back-end agnostic way.
-
Constructor Summary
Constructors Constructor Description PartialList()Instantiates a new PartialList.PartialList(List<T> list, long offset, long pageSize, long totalSize, PartialList.Relation totalSizeRelation)Instantiates a new PartialList.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tget(int index)Retrieves the element at the specified indexList<T>getList()Retrieves the limited list view.longgetOffset()Retrieves the offset of the first element of the view.longgetPageSize()Retrieves the number of elements this PartialList contains.StringgetScrollIdentifier()Retrieve the scroll identifier to make it possible to continue a scrolling list queryStringgetScrollTimeValidity()Retrieve the value of the scroll time validity to make it possible to continue a scrolling list querylonggetTotalSize()Retrieves the total size of elements in the original List.PartialList.RelationgetTotalSizeRelation()Retrieve the relation to the total site, wether it is equal to or greater than the value stored in the totalSize property.voidsetList(List<T> list)Sets the view list.voidsetOffset(long offset)voidsetPageSize(long pageSize)voidsetScrollIdentifier(String scrollIdentifier)voidsetScrollTimeValidity(String scrollTimeValidity)voidsetTotalSize(long totalSize)voidsetTotalSizeRelation(PartialList.Relation totalSizeRelation)intsize()Retrieves the size of this PartialList.
-
-
-
Constructor Detail
-
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 Detail
-
getList
public List<T> getList()
Retrieves the limited list view.- Returns:
- a List of the
sizeelements starting from theoffset-th one from the original, larger list
-
setList
public void setList(List<T> list)
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
public T get(int index)
Retrieves the element at the specified index- Parameters:
index- the index of the element to retrieve- Returns:
- the element at the specified index
-
getScrollIdentifier
public String 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
public void setScrollIdentifier(String scrollIdentifier)
-
getScrollTimeValidity
public String 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
public void setScrollTimeValidity(String scrollTimeValidity)
-
getTotalSizeRelation
public PartialList.Relation 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
public void setTotalSizeRelation(PartialList.Relation totalSizeRelation)
-
-