diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/SnowflakeIdGenerator.java b/src/main/java/xyz/zhouxy/plusone/commons/util/SnowflakeIdGenerator.java index 2e74309..7ed3888 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/SnowflakeIdGenerator.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/SnowflakeIdGenerator.java @@ -64,9 +64,9 @@ public class SnowflakeIdGenerator { * @param datacenterId 数据中心ID (0~31) */ public SnowflakeIdGenerator(final long workerId, final long datacenterId) { - Preconditions.checkArgument((workerId > MAX_WORKER_ID || workerId < 0), + Preconditions.checkArgument((workerId <= MAX_WORKER_ID || workerId >= 0), "WorkerId can't be greater than %s or less than 0.", MAX_WORKER_ID); - Preconditions.checkArgument((datacenterId > MAX_DATACENTER_ID || datacenterId < 0), + Preconditions.checkArgument((datacenterId <= MAX_DATACENTER_ID || datacenterId >= 0), "DatacenterId can't be greater than %s or less than 0.", MAX_DATACENTER_ID); this.datacenterIdAndWorkerId = (datacenterId << DATACENTER_ID_SHIFT) | (workerId << WORKER_ID_SHIFT);