auto commit
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* 版权属于:yitter(yitter@126.com)
|
||||
* 开源地址:https://gitee.com/yitter/idgenerator
|
||||
*/
|
||||
package com.yitter.contract;
|
||||
package com.github.yitter.contract;
|
||||
|
||||
public interface IIdGenerator {
|
||||
long newLong() throws IdGeneratorException;
|
||||
@@ -2,7 +2,7 @@
|
||||
* 版权属于:yitter(yitter@126.com)
|
||||
* 开源地址:https://gitee.com/yitter/idgenerator
|
||||
*/
|
||||
package com.yitter.contract;
|
||||
package com.github.yitter.contract;
|
||||
|
||||
public interface ISnowWorker {
|
||||
long nextId() throws IdGeneratorException;
|
||||
@@ -2,7 +2,7 @@
|
||||
* 版权属于:yitter(yitter@126.com)
|
||||
* 开源地址:https://gitee.com/yitter/idgenerator
|
||||
*/
|
||||
package com.yitter.contract;
|
||||
package com.github.yitter.contract;
|
||||
|
||||
public class IdGeneratorException extends RuntimeException {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* 版权属于:yitter(yitter@126.com)
|
||||
* 开源地址:https://gitee.com/yitter/idgenerator
|
||||
*/
|
||||
package com.yitter.contract;
|
||||
package com.github.yitter.contract;
|
||||
|
||||
/**
|
||||
* 雪花算法使用的参数
|
||||
@@ -2,7 +2,7 @@
|
||||
* 版权属于:yitter(yitter@126.com)
|
||||
* 开源地址:https://gitee.com/yitter/idgenerator
|
||||
*/
|
||||
package com.yitter.contract;
|
||||
package com.github.yitter.contract;
|
||||
|
||||
/**
|
||||
* Id生成时回调参数
|
||||
@@ -2,12 +2,12 @@
|
||||
* 版权属于:yitter(yitter@126.com)
|
||||
* 开源地址:https://gitee.com/yitter/idgenerator
|
||||
*/
|
||||
package com.yitter.core;
|
||||
package com.github.yitter.core;
|
||||
|
||||
import com.yitter.contract.ISnowWorker;
|
||||
import com.yitter.contract.IdGeneratorException;
|
||||
import com.yitter.contract.IdGeneratorOptions;
|
||||
import com.yitter.contract.OverCostActionArg;
|
||||
import com.github.yitter.contract.ISnowWorker;
|
||||
import com.github.yitter.contract.IdGeneratorOptions;
|
||||
import com.github.yitter.contract.OverCostActionArg;
|
||||
import com.github.yitter.contract.IdGeneratorException;
|
||||
|
||||
public class SnowWorkerM1 implements ISnowWorker {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 版权属于:yitter(yitter@126.com)
|
||||
* 开源地址:https://gitee.com/yitter/idgenerator
|
||||
*/
|
||||
package com.yitter.core;
|
||||
package com.github.yitter.core;
|
||||
|
||||
import com.yitter.contract.IdGeneratorException;
|
||||
import com.yitter.contract.IdGeneratorOptions;
|
||||
import com.github.yitter.contract.IdGeneratorOptions;
|
||||
import com.github.yitter.contract.IdGeneratorException;
|
||||
|
||||
public class SnowWorkerM2 extends SnowWorkerM1 {
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
* 版权属于:yitter(yitter@126.com)
|
||||
* 开源地址:https://gitee.com/yitter/idgenerator
|
||||
*/
|
||||
package com.yitter.idgen;
|
||||
package com.github.yitter.idgen;
|
||||
|
||||
import com.yitter.contract.ISnowWorker;
|
||||
import com.yitter.contract.IdGeneratorException;
|
||||
import com.yitter.contract.IdGeneratorOptions;
|
||||
import com.yitter.contract.IIdGenerator;
|
||||
import com.yitter.core.SnowWorkerM1;
|
||||
import com.yitter.core.SnowWorkerM2;
|
||||
import com.github.yitter.contract.IIdGenerator;
|
||||
import com.github.yitter.contract.ISnowWorker;
|
||||
import com.github.yitter.contract.IdGeneratorException;
|
||||
import com.github.yitter.contract.IdGeneratorOptions;
|
||||
import com.github.yitter.core.SnowWorkerM1;
|
||||
import com.github.yitter.core.SnowWorkerM2;
|
||||
|
||||
|
||||
public class DefaultIdGenerator implements IIdGenerator {
|
||||
@@ -1,45 +1,43 @@
|
||||
/*
|
||||
* 版权属于:yitter(yitter@126.com)
|
||||
* 开源地址:https://gitee.com/yitter/idgenerator
|
||||
*/
|
||||
package com.yitter.idgen;
|
||||
|
||||
import com.yitter.contract.IdGeneratorException;
|
||||
import com.yitter.contract.IdGeneratorOptions;
|
||||
import com.yitter.contract.IIdGenerator;
|
||||
|
||||
/**
|
||||
* 这是一个调用的例子,默认情况下,单机集成者可以直接使用 nextId()。
|
||||
*/
|
||||
public class YitIdHelper {
|
||||
|
||||
private static IIdGenerator idGenInstance = null;
|
||||
|
||||
public static IIdGenerator getIdGenInstance() {
|
||||
return idGenInstance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置参数,建议程序初始化时执行一次
|
||||
*
|
||||
* @param options
|
||||
*/
|
||||
public static void setIdGenerator(IdGeneratorOptions options) throws IdGeneratorException {
|
||||
idGenInstance = new DefaultIdGenerator(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成新的Id
|
||||
* 调用本方法前,请确保调用了 SetIdGenerator 方法做初始化。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static long nextId() throws IdGeneratorException {
|
||||
if (idGenInstance == null) {
|
||||
idGenInstance = new DefaultIdGenerator(new IdGeneratorOptions((short) 1));
|
||||
}
|
||||
|
||||
return idGenInstance.newLong();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 版权属于:yitter(yitter@126.com)
|
||||
* 开源地址:https://gitee.com/yitter/idgenerator
|
||||
*/
|
||||
package com.github.yitter.idgen;
|
||||
|
||||
import com.github.yitter.contract.IIdGenerator;
|
||||
import com.github.yitter.contract.IdGeneratorException;
|
||||
import com.github.yitter.contract.IdGeneratorOptions;
|
||||
|
||||
/**
|
||||
* 这是一个调用的例子,默认情况下,单机集成者可以直接使用 nextId()。
|
||||
*/
|
||||
public class YitIdHelper {
|
||||
|
||||
private static IIdGenerator idGenInstance = null;
|
||||
|
||||
public static IIdGenerator getIdGenInstance() {
|
||||
return idGenInstance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置参数,建议程序初始化时执行一次
|
||||
*/
|
||||
public static void setIdGenerator(IdGeneratorOptions options) throws IdGeneratorException {
|
||||
idGenInstance = new DefaultIdGenerator(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成新的Id
|
||||
* 调用本方法前,请确保调用了 SetIdGenerator 方法做初始化。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static long nextId() throws IdGeneratorException {
|
||||
if (idGenInstance == null) {
|
||||
idGenInstance = new DefaultIdGenerator(new IdGeneratorOptions((short) 1));
|
||||
}
|
||||
|
||||
return idGenInstance.newLong();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.yitter.test;
|
||||
package com.github.yitter.test;
|
||||
|
||||
import com.yitter.contract.IIdGenerator;
|
||||
import com.github.yitter.contract.IIdGenerator;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.yitter.test;
|
||||
package com.github.yitter.test;
|
||||
|
||||
import com.yitter.contract.IdGeneratorOptions;
|
||||
import com.yitter.contract.IIdGenerator;
|
||||
import com.yitter.idgen.DefaultIdGenerator;
|
||||
import com.yitter.idgen.YitIdHelper;
|
||||
import com.github.yitter.contract.IIdGenerator;
|
||||
import com.github.yitter.contract.IdGeneratorOptions;
|
||||
import com.github.yitter.idgen.DefaultIdGenerator;
|
||||
import com.github.yitter.idgen.YitIdHelper;
|
||||
|
||||
public class StartUp {
|
||||
|
||||
Reference in New Issue
Block a user