1
0
mirror of synced 2025-12-14 17:18:10 +08:00

auto commit

This commit is contained in:
yitter
2021-03-30 11:42:23 +08:00
parent af6c0955e2
commit c08ddab813
5 changed files with 11 additions and 12 deletions

View File

@@ -6,7 +6,7 @@
<groupId>com.github.yitter</groupId>
<artifactId>yitter-idgenerator</artifactId>
<version>1.0.3-SNAPSHOT</version>
<version>1.0.4-SNAPSHOT</version>
<packaging>jar</packaging>
<name>yitter-idgenerator</name>

View File

@@ -51,7 +51,7 @@ public class IdGeneratorOptions {
/**
* 最小序列数(含)
* 默认5不小于1不大于MaxSeqNumber
* 默认5不小于5不大于MaxSeqNumber
*/
public short MinSeqNumber = 5;

View File

@@ -63,7 +63,7 @@ public class SnowWorkerM1 implements ISnowWorker {
WorkerId = options.WorkerId;
WorkerIdBitLength = options.WorkerIdBitLength == 0 ? 6 : options.WorkerIdBitLength;
SeqBitLength = options.SeqBitLength == 0 ? 6 : options.SeqBitLength;
MaxSeqNumber = options.MaxSeqNumber > 0 ? options.MaxSeqNumber : (int) Math.pow(2, SeqBitLength) - 1;
MaxSeqNumber = options.MaxSeqNumber > 0 ? options.MaxSeqNumber : (1 << SeqBitLength) - 1;
MinSeqNumber = options.MinSeqNumber;
TopOverCostCount = options.TopOverCostCount;
BaseTime = options.BaseTime != 0 ? options.BaseTime : 1582136402000L;

View File

@@ -47,17 +47,15 @@ public class DefaultIdGenerator implements IIdGenerator {
}
int maxValue = maxSeqNumber;
if (options.MinSeqNumber < 1 || options.MinSeqNumber > maxValue) {
throw new IdGeneratorException("MinSeqNumber error. (range:[1, " + maxValue + "]");
if (options.MinSeqNumber < 5 || options.MinSeqNumber > maxValue) {
throw new IdGeneratorException("MinSeqNumber error. (range:[5, " + maxValue + "]");
}
switch (options.Method) {
case 1:
_SnowWorker = new SnowWorkerM1(options);
break;
case 2:
_SnowWorker = new SnowWorkerM2(options);
break;
case 1:
default:
_SnowWorker = new SnowWorkerM1(options);
break;