add documentation
This commit is contained in:
parent
01c6dd2e66
commit
c82670e3de
@ -1,26 +1,10 @@
|
|||||||
import java.util.Properties
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.dokka)
|
|
||||||
alias(libs.plugins.kotlin.jvm)
|
|
||||||
alias(libs.plugins.maven.publish)
|
alias(libs.plugins.maven.publish)
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "ai.neuon.roadplus.utility"
|
group = "ai.neuon.roadplus.utility"
|
||||||
version = "1.0.0"
|
version = "1.0.2"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation(libs.kotlinx.serialization.json)
|
|
||||||
testImplementation(kotlin("test"))
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
|
||||||
kotlin {
|
|
||||||
jvmToolchain(11)
|
|
||||||
}
|
|
||||||
@ -4,7 +4,8 @@ import java.util.Properties
|
|||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.dokka)
|
alias(libs.plugins.dokka)
|
||||||
alias(libs.plugins.kotlin.jvm)
|
alias(libs.plugins.kotlin.jvm)
|
||||||
alias(libs.plugins.maven.publish)}
|
alias(libs.plugins.maven.publish)
|
||||||
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@ -1,5 +1,18 @@
|
|||||||
package ai.neuon.utility.paging
|
package ai.neuon.utility.paging
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines how results should be paginated when fetching data.
|
||||||
|
*
|
||||||
|
* @property index Zero-based page index, indicating which page of results to load.
|
||||||
|
* @property size Number of items to include in a single page.
|
||||||
|
*
|
||||||
|
* Validation rules:
|
||||||
|
* - index must be >= 0
|
||||||
|
* - size must be > 0
|
||||||
|
*
|
||||||
|
* Used by repository or service methods to control
|
||||||
|
* data retrieval and limit result sizes for performance.
|
||||||
|
*/
|
||||||
data class PagingConfig(
|
data class PagingConfig(
|
||||||
val index: Int,
|
val index: Int,
|
||||||
val size: Int,
|
val size: Int,
|
||||||
|
|||||||
@ -7,6 +7,27 @@ import kotlin.math.ceil
|
|||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.roundToLong
|
import kotlin.math.roundToLong
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a single page of results in a paginated query.
|
||||||
|
*
|
||||||
|
* @param i The zero-based index of the current page.
|
||||||
|
* @param pageSize Number of items in each page.
|
||||||
|
* @param totalItemsCount Optional total number of items available across all pages.
|
||||||
|
* @param list The list of items in the current page.
|
||||||
|
*
|
||||||
|
* ## Purpose
|
||||||
|
* - Used as the return type for paginated queries (e.g., getPermissions).
|
||||||
|
* - Couples the actual result list with pagination metadata.
|
||||||
|
*
|
||||||
|
* ## Companion object helpers
|
||||||
|
* - [empty]: Creates an empty page with the given index and size.
|
||||||
|
* - [empty(config)]: Creates an empty page using a [PagingConfig].
|
||||||
|
*
|
||||||
|
* ## buildPagingJsonObject
|
||||||
|
* - Serializes the pagination metadata into JSON format:
|
||||||
|
* - "config" → Contains the current page index and page size.
|
||||||
|
* - "page" → Can include the total number of pages if totalItemsCount is set.
|
||||||
|
*/
|
||||||
data class PagingData<T>(
|
data class PagingData<T>(
|
||||||
val i: Int, val pageSize: Int, val totalItemsCount: Long? = null,
|
val i: Int, val pageSize: Int, val totalItemsCount: Long? = null,
|
||||||
val list: List<T>,
|
val list: List<T>,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user