com.github.sylphlike.framework.utils.sequence.IDProvider Maven / Gradle / Ivy
package com.github.sylphlike.framework.utils.sequence;
/**
* ID生成客户端
* time 10/09/2020 18:19 星期四 (dd/MM/YYYY HH:mm)
*
email [email protected]
*
* @author Gopal.pan
* @version 1.0.0
*/
public class IDProvider {
private static final StandardSequence standardSequence = new StandardSequence();
private static final GeneSequence geneSequence = new GeneSequence();
/**
* 标准snowflake 算法
*
time 13:56 2020/9/22 (HH:mm yyyy/MM/dd)
*
email [email protected]
*
* @return long
* @author Gopal.pan
*/
public static long uniqueID(){
return standardSequence.nextId();
}
/**
* 雪花算法 + 基因法
*
time 11:22 2020/9/23 (HH:mm yyyy/MM/dd)
*
email [email protected]
* @param originalId 原始序列号
* @return long
* @author Gopal.pan
*/
public static long uniqueGeneID(Long originalId){
return geneSequence.nextId(originalId);
}
}