commonMain.dev.inmo.micro_utils.pagination.utils.GetAll.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of micro_utils.pagination.common-jvm Show documentation
Show all versions of micro_utils.pagination.common-jvm Show documentation
It is set of projects with micro tools for avoiding of routines coding
The newest version!
package dev.inmo.micro_utils.pagination.utils
import dev.inmo.micro_utils.pagination.*
inline fun getAll(
initialPagination: Pagination = FirstPagePagination(),
paginationMapper: (PaginationResult) -> Pagination?,
block: (Pagination) -> PaginationResult
): List {
val results = mutableListOf()
doForAll(initialPagination, paginationMapper) {
block(it).also {
results.addAll(it.results)
}
}
return results.toList()
}
inline fun R.getAllBy(
initialPagination: Pagination = FirstPagePagination(),
paginationMapper: R.(PaginationResult) -> Pagination?,
block: R.(Pagination) -> PaginationResult
): List = getAll(
initialPagination,
{ paginationMapper(it) },
{ block(it) }
)
inline fun getAllWithNextPaging(
initialPagination: Pagination = FirstPagePagination(),
block: (Pagination) -> PaginationResult
): List = getAll(
initialPagination,
{ it.nextPageIfNotEmptyOrLastPage() },
block
)
inline fun R.getAllByWithNextPaging(
initialPagination: Pagination = FirstPagePagination(),
block: R.(Pagination) -> PaginationResult
): List = getAllWithNextPaging(
initialPagination,
{ block(it) }
)
inline fun getAllWithCurrentPaging(
initialPagination: Pagination = FirstPagePagination(),
block: (Pagination) -> PaginationResult
): List = getAll(
initialPagination,
{ it.thisPageIfNotEmptyOrLastPage() },
block
)
inline fun R.getAllByWithCurrentPaging(
initialPagination: Pagination = FirstPagePagination(),
block: R.(Pagination) -> PaginationResult
): List = getAllWithCurrentPaging(
initialPagination
) { block(it) }
© 2015 - 2025 Weber Informatics LLC | Privacy Policy