diff --git a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationResult.kt b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationResult.kt index 96bb73b66b0..6a62cf5bdfa 100644 --- a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationResult.kt +++ b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/PaginationResult.kt @@ -3,15 +3,24 @@ package dev.inmo.micro_utils.pagination import kotlinx.serialization.* import kotlin.math.ceil +/** + * @param page Current page number + * @param size Current page size. It can be greater than size of [results] + * @param results Result objects + * @param objectsNumber Count of all objects across all pages + */ @Serializable data class PaginationResult( override val page: Int, override val size: Int, val results: List, - val objectsCount: Long + val objectsNumber: Long ) : Pagination { + /** + * Amount of pages for current pagination + */ @EncodeDefault - val pagesNumber: Int = ceil(objectsCount / size.toFloat()).toInt() + val pagesNumber: Int = ceil(objectsNumber / size.toFloat()).toInt() constructor( page: Int, @@ -45,7 +54,7 @@ fun emptyPaginationResult() = PaginationResult(0, 0, emptyList(), 0L) */ fun PaginationResult.changeResultsUnchecked( data: List -): PaginationResult = PaginationResult(page, size, data, objectsCount) +): PaginationResult = PaginationResult(page, size, data, objectsNumber) /** * @return New [PaginationResult] with [data] with checking of data sizes equality */ diff --git a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/SimplePagination.kt b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/SimplePagination.kt index fed71b34d72..11d2d90fbfd 100644 --- a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/SimplePagination.kt +++ b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/SimplePagination.kt @@ -26,6 +26,10 @@ inline fun Pagination.nextPage() = size ) +/** + * @param page Current page number + * @param size Current page size + */ @Serializable data class SimplePagination( override val page: Int,