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 class
PartialList.Relation
This 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 T
get(int index)
Retrieves the element at the specified indexList<T>
getList()
Retrieves the limited list view.long
getOffset()
Retrieves the offset of the first element of the view.long
getPageSize()
Retrieves the number of elements this PartialList contains.String
getScrollIdentifier()
Retrieve the scroll identifier to make it possible to continue a scrolling list queryString
getScrollTimeValidity()
Retrieve the value of the scroll time validity to make it possible to continue a scrolling list querylong
getTotalSize()
Retrieves the total size of elements in the original List.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.void
setList(List<T> list)
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 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
size
elements 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)
-
-