From 5213a2ff8e4079e04693d2f1c495f97b82e28188 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 26 Jul 2022 14:58:14 +0600 Subject: [PATCH] add kdocs for pagination --- .../micro_utils/pagination/PaginationResult.kt | 15 ++++++++++++--- .../micro_utils/pagination/SimplePagination.kt | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) 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,