Class AbstractSnowflakeId

java.lang.Object
me.ahoo.cosid.snowflake.AbstractSnowflakeId
All Implemented Interfaces:
IdGenerator, SnowflakeId, Statistical, StringIdGenerator
Direct Known Subclasses:
MillisecondSnowflakeId, SecondSnowflakeId

public abstract class AbstractSnowflakeId extends Object implements SnowflakeId
Abstract SnowflakeId.
  • Field Details

    • epoch

      protected final long epoch
    • timestampBit

      protected final int timestampBit
    • machineBit

      protected final int machineBit
    • sequenceBit

      protected final int sequenceBit
    • maxTimestamp

      protected final long maxTimestamp
    • maxSequence

      protected final long maxSequence
    • maxMachine

      protected final int maxMachine
    • machineLeft

      protected final long machineLeft
    • timestampLeft

      protected final long timestampLeft
    • machineId

      protected final long machineId
      WARN:machineLeft greater than 30 will cause overflow, so machineId should be long when calculating.
    • sequence

      protected long sequence
    • lastTimestamp

      protected long lastTimestamp
  • Constructor Details

    • AbstractSnowflakeId

      public AbstractSnowflakeId(long epoch, int timestampBit, int machineBit, int sequenceBit, int machineId, long sequenceResetThreshold)
  • Method Details