Class Paginator.PaginatorBuilder<T extends Model>

java.lang.Object
org.javalite.activejdbc.Paginator.PaginatorBuilder<T>
Enclosing class:
Paginator<T extends Model>

public static class Paginator.PaginatorBuilder<T extends Model> extends Object
Provides a builder pattern to create new instances of paginator.
  • Constructor Details

    • PaginatorBuilder

      public PaginatorBuilder()
  • Method Details

    • modelClass

      public Paginator.PaginatorBuilder<T> modelClass(Class<T> modelClass)
      Model class mapped to a table.>
      Parameters:
      modelClass - Model class mapped to a table.>
      Returns:
      self
    • pageSize

      public Paginator.PaginatorBuilder<T> pageSize(int pageSize)
      Page size - number of items in a page
      Parameters:
      pageSize - Page size - number of items in a page
    • orderBy

      public Paginator.PaginatorBuilder<T> orderBy(String orderBys)
      Parameters:
      orderBys - a comma-separated list of field names followed by either "desc" or "asc"
    • suppressCounts

      public Paginator.PaginatorBuilder<T> suppressCounts(boolean 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 time Paginator.getCount() is called from Paginator.hasNext() as well.
      Parameters:
      suppressCounts - suppress counts every time.
    • query

      public Paginator.PaginatorBuilder<T> query(String 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

      public Paginator.PaginatorBuilder<T> countQuery(String 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 than COUNT(*), since that is the value that us used by default.
      Parameters:
      countQuery - Part of the query that is responsible for "count. Example: count(*)" or COUNT(DISTINCT(u.id).
    • params

      public Paginator.PaginatorBuilder<T> params(Object... params)
      Array of parameters in case a query is parametrized
      Parameters:
      params - Array of parameters in case a query is parametrized
    • currentPageIndex

      public Paginator.PaginatorBuilder<T> currentPageIndex(int currentPageIndex, boolean skipCheck)
      See Also:
      Paginator.setCurrentPageIndex(int, boolean)
    • create

      public Paginator<T> create()
      Terminal method to create an instance of Paginator.
      Returns:
      new Paginator properly configured.