Package-level declarations

Types

Link copied to clipboard
interface Pagination : ClosedRange<Int>

Base interface of pagination

Link copied to clipboard
@Serializable
data class PaginationResult<T>(val page: Int, val size: Int, val results: List<T>, val objectsNumber: Long) : Pagination
Link copied to clipboard
@Serializable
data class SimplePagination(val page: Int, val size: Int) : Pagination

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val defaultLargePageSize: Int = 10
Link copied to clipboard
const val defaultMediumPageSize: Int = 5
Link copied to clipboard
const val defaultSmallPageSize: Int = 2
Link copied to clipboard
Link copied to clipboard
val ERROR CLASS: Symbol not found for ApplicationCall.extractPagination: Pagination
val ERROR CLASS: Symbol not found for Parameters.extractPagination: Pagination
Link copied to clipboard

First number in index of objects. It can be used as offset for databases or other data sources

Link copied to clipboard

Logical shortcut for comparison that page is 0

Link copied to clipboard
Link copied to clipboard

Last number in index of objects. In fact, one Pagination object represent data in next range:

Link copied to clipboard

Last number in index of objects. In fact, one Pagination object represent data in next range:

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun calculatePage(firstIndex: Int, resultsSize: Int): Int
Link copied to clipboard
fun calculatePagesNumber(datasetSize: Int, pageSize: Int): Int
fun calculatePagesNumber(datasetSize: Long, pageSize: Int): Int

Calculates pages count for given datasetSize

fun calculatePagesNumber(pageSize: Int, datasetSize: Long): Int

Calculates pages count for given datasetSize. As a fact, it is shortcut for calculatePagesNumber

Link copied to clipboard
Link copied to clipboard
fun <T> List<T>.createPaginationResult(pagination: Pagination, commonObjectsNumber: Long): PaginationResult<T>
fun <T> List<T>.createPaginationResult(firstIndex: Int, commonObjectsNumber: Long): PaginationResult<T>
Link copied to clipboard
inline fun doWithPagination(startPagination: Pagination = FirstPagePagination(), requestMaker: (pagination: Pagination) -> Pagination?)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
inline fun FirstPagePagination(size: Int = defaultPaginationPageSize): SimplePagination
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
inline fun <T, PR : PaginationResult<T>> PR.nextPageIfTrue(condition: PR.() -> Boolean): SimplePagination?
Link copied to clipboard
fun ERROR CLASS: Symbol not found for Query.paginate(with: Pagination, orderBy: Pair<ERROR CLASS: Symbol not found for Expression<*>, ERROR CLASS: Symbol not found for SortOrder>? = null): ERROR CLASS: Cannot infer argument for type parameter R

Applies pagination to this Exposed Query. Sets the limit and offset based on the pagination parameters, and optionally orders the results.

fun ERROR CLASS: Symbol not found for Query.paginate(with: Pagination, orderBy: ERROR CLASS: Symbol not found for Expression<*>??, reversed: Boolean = false): ERROR CLASS: Cannot infer argument for type parameter R

Applies pagination to this Exposed Query with optional ordering and reversal. Sets the limit and offset based on the pagination parameters.

Link copied to clipboard
fun Pagination(page: Int, size: Int): SimplePagination

Factory for SimplePagination

Link copied to clipboard
fun PaginationByIndexes(firstIndex: Int, lastIndex: Int): SimplePagination
Link copied to clipboard

This method DO NOT check Pagination.page of receiver. Returns pagination for previous page

Link copied to clipboard
inline fun <T, PR : PaginationResult<T>> PR.thisPageIfTrue(condition: PR.() -> Boolean): PR?