Package org.javalite.activejdbc
Class Paginator.PaginatorBuilder<T extends Model>
java.lang.Object
org.javalite.activejdbc.Paginator.PaginatorBuilder<T>
Provides a builder pattern to create new instances of paginator.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncountQuery(String countQuery)
Part of the query that is responsible for count.create()
Terminal method to create an instance of Paginator.currentPageIndex(int currentPageIndex, boolean skipCheck)
modelClass(Class<T> modelClass)
Model class mapped to a table.>pageSize(int pageSize)
Page size - number of items in a pageArray of parameters in case a query is parametrizedsuppressCounts(boolean suppressCounts)
Suppress calling "select count(*)...
-
Constructor Details
-
PaginatorBuilder
public PaginatorBuilder()
-
-
Method Details
-
modelClass
Model class mapped to a table.>- Parameters:
modelClass
- Model class mapped to a table.>- Returns:
- self
-
pageSize
Page size - number of items in a page- Parameters:
pageSize
- Page size - number of items in a page
-
orderBy
- Parameters:
orderBys
- a comma-separated list of field names followed by either "desc" or "asc"
-
suppressCounts
Suppress calling "select count(*)... " on a table each time. If set to true, it will call count only once. If set to false, it will call count each timePaginator.getCount()
is called fromPaginator.hasNext()
as well.- Parameters:
suppressCounts
- suppress counts every time.
-
query
- Parameters:
query
- Query that will be applied every time a new page is requested; this query should not contain limit, offset or order by clauses of any kind, Paginator will do this automatically. This parameter can have two forms, a sub-query or a full query.
-
countQuery
Part of the query that is responsible for count. Example:COUNT(DISTINCT(u.id)
. Only use this method if you need something more complex thanCOUNT(*)
, since that is the value that us used by default.- Parameters:
countQuery
- Part of the query that is responsible for "count. Example:count(*)
" orCOUNT(DISTINCT(u.id)
.
-
params
Array of parameters in case a query is parametrized- Parameters:
params
- Array of parameters in case a query is parametrized
-
currentPageIndex
-
create
Terminal method to create an instance of Paginator.- Returns:
- new Paginator properly configured.
-