com.ineunet.knife.seq.IdSequence Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2013-2018 iNeunet OpenSource and the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.ineunet.knife.seq;
import java.util.Date;
import com.ineunet.knife.jdbc.annotation.Table;
/**
*
* @author [email protected]
* Created on 2015年6月13日
*/
@Table(name = "knife_id_sequence")
public class IdSequence {
private Long id; // 自增id
private String group; // label的前缀,一般是数据库名,主要用于查询分组用于初始化加载
private String label; // 一般是库名.表名,必须唯一
private int interval = 2000; // 步长,默认2000
private long nextId = interval + 1; // 初始为1
private Date updateTime;
public IdSequence() {}
public IdSequence(String group, String label) {
this(group, label, 2000);
}
public IdSequence(String group, String label, int interval) {
this(group, label, interval, interval + 1, new Date());
}
public IdSequence(String group, String label, int interval, long nextId, Date updateTime) {
this.group = group;
this.label = label;
this.interval = interval;
this.nextId = nextId;
this.updateTime = updateTime;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public int getInterval() {
return interval;
}
public void setInterval(int interval) {
this.interval = interval;
}
public long getNextId() {
return nextId;
}
public void setNextId(long nextId) {
this.nextId = nextId;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy