Package org.pipservices3.commons.data
Class PagingParams
java.lang.Object
org.pipservices3.commons.data.PagingParams
Data transfer object to pass paging parameters for queries.
The page is defined by two parameters.
The
skip parameter defines number of items to skip.
The paging parameter sets how many items to return in a page.
And the optional total parameter tells to return total number of items in the query.
Remember: not all implementations support total parameter
because its generation may lead to severe performance implications.
### Example ###
FilterParams filter = FilterParams.fromTuples("type", "Type1");
PagingParams paging = new PagingParams(0, 100);
myDataClient.getDataByFilter(filter, paging);
-
Constructor Summary
ConstructorsConstructorDescriptionPagingParams(Object skip, Object take, Object total) Creates a new instance and sets its values. -
Method Summary
Modifier and TypeMethodDescriptionstatic PagingParamsfromMap(AnyValueMap map) Creates a new PagingParams and sets it parameters from the AnyValueMap mapstatic PagingParamsfromMap(StringValueMap map) Creates a new PagingParams and sets it parameters from the StringValueMap mapstatic PagingParamsfromTuples(Object... tuples) Creates a new PagingParams from a list of key-value pairs called tuples.static PagingParamsConverts specified value into PagingParams.getSkip()Gets the number of items to skip.longgetSkip(long minSkip) Gets the number of items to skip.getTake()Gets the number of items to return in a page.longgetTake(long maxTake) Gets the number of items to return in a page.booleanhasTotal()voidsetSkip(long value) Sets value to skipvoidsetTake(long value) Sets value to takevoidsetTotal(boolean value) Sets value to total
-
Constructor Details
-
PagingParams
public PagingParams() -
PagingParams
Creates a new instance and sets its values.- Parameters:
skip- the number of items to skip.take- the number of items to return.total- true to return the total number of items.
-
-
Method Details
-
getSkip
Gets the number of items to skip.- Returns:
- the number of items to skip.
-
getSkip
public long getSkip(long minSkip) Gets the number of items to skip.- Parameters:
minSkip- the minimum number of items to skip.- Returns:
- the number of items to skip.
-
getTake
Gets the number of items to return in a page.- Returns:
- the number of items to return.
-
setSkip
public void setSkip(long value) Sets value to skip- Parameters:
value- value to set skip
-
getTake
public long getTake(long maxTake) Gets the number of items to return in a page.- Parameters:
maxTake- the maximum number of items to return.- Returns:
- the number of items to return.
-
setTake
public void setTake(long value) Sets value to take- Parameters:
value- value to set take
-
hasTotal
public boolean hasTotal()- Returns:
- value of total
-
setTotal
public void setTotal(boolean value) Sets value to total- Parameters:
value- value to set total
-
fromValue
Converts specified value into PagingParams.- Parameters:
value- value to be converted- Returns:
- a newly created PagingParams.
-
fromTuples
Creates a new PagingParams from a list of key-value pairs called tuples.- Parameters:
tuples- a list of values where odd elements are keys and the following even elements are values- Returns:
- a newly created PagingParams.
-
fromMap
Creates a new PagingParams and sets it parameters from the AnyValueMap map- Parameters:
map- a AnyValueMap to initialize this PagingParams- Returns:
- a newly created PagingParams.
-
fromMap
Creates a new PagingParams and sets it parameters from the StringValueMap map- Parameters:
map- a StringValueMap to initialize this PagingParams- Returns:
- a newly created PagingParams.
-