All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tianyisoft.database.util.Page.kt Maven / Gradle / Ivy

The newest version!
package com.tianyisoft.database.util

import kotlin.math.ceil

class Page: java.io.Serializable {
    var data: List = ArrayList()
    var meta: Meta = Meta()

    companion object {
        private const val serialVersionUID: Long = 198912190701L

        @JvmStatic
        fun  new(page: Int, pageSize: Int, total: Long, data: List): Page {
            val p = Page()
            p.data = data
            with(p.meta) {
                current = page
                size = pageSize
                this.total = total
                pages = ceil(total / pageSize.toDouble()).toInt()
            }
            return p
        }

        @JvmStatic
        @JvmOverloads
        fun  empty(page: Int = 1, pageSize: Int = 15): Page {
            return new(page, pageSize, 0, ArrayList())
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy