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

com.swak.core.seq.IdSegment Maven / Gradle / Ivy

The newest version!
package com.swak.core.seq;

import java.util.Date;

/**
 * 分段信息
 * 
 * @author liuliang8
 *
 */
public class IdSegment {
    private Long minId;
    private Long maxId;

    private Long step;

    private Long middleId;

    private Date lastUpdateTime;
    private Date currentUpdateTime;

    public IdSegment() {

    }

    public Date getLastUpdateTime() {
        return lastUpdateTime;
    }

    public void setLastUpdateTime(Date lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
    }

    public Date getCurrentUpdateTime() {
        return currentUpdateTime;
    }

    public void setCurrentUpdateTime(Date currentUpdateTime) {
        this.currentUpdateTime = currentUpdateTime;
    }

    public Long getMiddleId() {

        if (this.middleId == null) {
            this.middleId = this.maxId - (long) Math.round(step / 2);
        }
        return middleId;
    }

    public Long getMinId() {
        if (this.minId == null) {
            if (this.maxId != null && this.step != null) {
                this.minId = this.maxId - this.step;
            } else {
                throw new RuntimeException("maxid or step is null");
            }
        }

        return minId;
    }


    public Long getMaxId() {
        return maxId;
    }

    public void setMaxId(Long maxId) {
        this.maxId = maxId;
    }

    public Long getStep() {
        return step;
    }

    public void setStep(Long step) {
        this.step = step;
    }

    @Override
    public String toString() {
        return "IdSegment [minId=" + minId + ", maxId=" + maxId + ", step=" + step + ", middleId="
            + middleId + ", lastUpdateTime=" + lastUpdateTime + ", currentUpdateTime="
            + currentUpdateTime + "]";
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy