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

commons.box.app.DataPage Maven / Gradle / Ivy

The newest version!
package commons.box.app;

import java.util.Objects;

/**
 * 表示数据的分页
 */
public class DataPage implements DataObject {
    private long offset = 0;
    private long limit = -1;
    private long count = -1;

    public DataPage() {
    }

    public DataPage(long offset, long limit) {
        this.offset = offset;
        this.limit = limit;
    }

    public DataPage(long offset, long limit, long count) {
        this.offset = offset;
        this.limit = limit;
        this.count = count;
    }


    public static DataPage inst() {
        return new DataPage();
    }

    public static DataPage inst(long offset, long limit) {
        return inst().page(offset, limit);
    }

    public static DataPage inst(long offset, long limit, long count) {
        return inst().page(offset, limit).count(count);
    }

    public DataPage page(long offset, long limit) {
        this.setOffset(offset);
        this.setLimit(limit);
        return this;
    }

    public DataPage count(long count) {
        this.setCount(count);
        return this;
    }

    public long getOffset() {
        return offset;
    }

    public void setOffset(long offset) {
        this.offset = offset;
    }

    public long getLimit() {
        return limit;
    }

    public void setLimit(long limit) {
        this.limit = limit;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        DataPage dataPage = (DataPage) o;
        return getOffset() == dataPage.getOffset() &&
                getLimit() == dataPage.getLimit() &&
                getCount() == dataPage.getCount();
    }

    @Override
    public int hashCode() {
        return Objects.hash(getOffset(), getLimit(), getCount());
    }

    @Override
    public String toString() {
        return "DataPage{" +
                "offset=" + offset +
                ", limit=" + limit +
                ", count=" + count +
                '}';
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy