- java.lang.Object
-
- com.erudika.para.core.utils.Pager
-
-
Constructor Summary
Constructors Constructor Description Pager()No-args constructor.Pager(int limit)Default constructor with limit.Pager(long page, int limit)Default constructor with a page and count.Pager(long page, String sortby, boolean desc, int limit)Default constructor with a page, count, sortby, desc and limit.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetCount()The total number of results for a query.StringgetLastKey()Returns the last key from last page.intgetLimit()Limits the maximum number of results to return in one page.StringgetName()Name of this pager object (optional).longgetPage()Page number.List<String>getSelect()Selects the field names to be returned.StringgetSortby()The name of the field used when sorting the results.booleanisDesc()The sort order.voidsetCount(long count)Set the value of count.voidsetDesc(boolean desc)Sets the value of desc.voidsetLastKey(String lastKey)Sets the last key from last page.voidsetLimit(int limit)Set the value of limit.voidsetName(String name)Set the value of name.voidsetPage(long page)Set the value of page.voidsetSelect(List<String> select)Sets the fields that are selected to appear in the response from the API.voidsetSortby(String sortby)Sets the value of sortby.StringtoString()
-
-
-
Constructor Detail
-
Pager
public Pager()
No-args constructor.
-
Pager
public Pager(int limit)
Default constructor with limit.- Parameters:
limit- the results limit
-
Pager
public Pager(long page, int limit)Default constructor with a page and count.- Parameters:
page- the page numberlimit- the results limit
-
Pager
public Pager(long page, String sortby, boolean desc, int limit)Default constructor with a page, count, sortby, desc and limit.- Parameters:
page- the page numbersortby- name of property to sort bydesc- sort orderlimit- the results limit
-
-
Method Detail
-
getLastKey
public String getLastKey()
Returns the last key from last page. Used for scanning and pagination.- Returns:
- the last key to continue from
-
setLastKey
public void setLastKey(String lastKey)
Sets the last key from last page. Used for scanning and pagination.- Parameters:
lastKey- last id
-
getName
public String getName()
Name of this pager object (optional). Used to distinguish between multiple pagers.- Returns:
- the name
-
setName
public void setName(String name)
Set the value of name.- Parameters:
name- the name (optional)
-
getSortby
public String getSortby()
The name of the field used when sorting the results.- Returns:
- the name of the field or "timestamp" as the default sorting
-
setSortby
public void setSortby(String sortby)
Sets the value of sortby.- Parameters:
sortby- the sort field
-
isDesc
public boolean isDesc()
The sort order. Default: descending (true)- Returns:
- true if descending
-
setDesc
public void setDesc(boolean desc)
Sets the value of desc.- Parameters:
desc- true if descending order
-
getLimit
public int getLimit()
Limits the maximum number of results to return in one page.- Returns:
- the max number of results in one page
-
setLimit
public void setLimit(int limit)
Set the value of limit.- Parameters:
limit- the max number of results in one page
-
getCount
public long getCount()
The total number of results for a query.- Returns:
- total count of results
-
setCount
public void setCount(long count)
Set the value of count.- Parameters:
count- total count
-
getPage
public long getPage()
Page number. Usually starts from 1...- Returns:
- the page number
-
setPage
public void setPage(long page)
Set the value of page.- Parameters:
page- the page number
-
getSelect
public List<String> getSelect()
Selects the field names to be returned.- Returns:
- a set of field names
-
setSelect
public void setSelect(List<String> select)
Sets the fields that are selected to appear in the response from the API.- Parameters:
select- a set of field names
-
-