net.nemerosa.ontrack.model.pagination.PaginatedList.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ontrack-model Show documentation
Show all versions of ontrack-model Show documentation
Ontrack module: ontrack-model
package net.nemerosa.ontrack.model.pagination
/**
* List of objects with some pagination information.
*
* @property pageInfo Information about the current page
* @property pageItems Items in the current page
*/
class PaginatedList(
val pageInfo: PageInfo,
val pageItems: List
) {
companion object {
@JvmStatic
fun create(
items: List,
offset: Int,
pageSize: Int
) = create(
items.subList(
maxOf(offset, 0),
maxOf(minOf(offset + pageSize, items.size), 0)
),
offset,
pageSize,
items.size
)
fun create(
items: List,
offset: Int,
pageSize: Int,
total: Int): PaginatedList {
return PaginatedList(
pageInfo = PageInfo(
totalSize = total,
currentOffset = offset,
currentSize = items.size,
previousPage = PageRequest(offset, items.size).previous(total, pageSize),
nextPage = PageRequest(offset, items.size).next(total, pageSize)
),
pageItems = items
)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy