fun.fengwk.convention4j.springboot.starter.snowflake.GlobalSnowflakeIdGenerator Maven / Gradle / Ivy
The newest version!
package fun.fengwk.convention4j.springboot.starter.snowflake;
import fun.fengwk.convention4j.common.idgen.NamespaceIdGenerator;
/**
* @author fengwk
*/
public class GlobalSnowflakeIdGenerator {
private static volatile NamespaceIdGenerator instance;
private GlobalSnowflakeIdGenerator() {}
/**
* 设置全局SnowflakeIdGenerator实例。
*
* @param snowflakeIdGenerator
*/
static void setInstance(NamespaceIdGenerator snowflakeIdGenerator) {
instance = snowflakeIdGenerator;
}
public static long next(String namespace) {
return instance.next(namespace);
}
public static long next(Class namespace) {
return instance.next(namespace);
}
}