Class SnowflakeCreatorBuilder

java.lang.Object
de.chojo.jdautil.util.SnowflakeCreatorBuilder

public class SnowflakeCreatorBuilder extends Object
  • Constructor Details

    • SnowflakeCreatorBuilder

      public SnowflakeCreatorBuilder()
  • Method Details

    • withWorkerId

      public SnowflakeCreatorBuilder withWorkerId(long workerId)
      Set the worker id for the creator. This id is usually the same for each running application instance
      Parameters:
      workerId - worker id
      Returns:
      builder instance
      Throws:
      IllegalStateException - when the id is larger than the max id or smaller than 0
    • withProcessId

      public SnowflakeCreatorBuilder withProcessId(long processId)
      Set the process id for the creator. If the id is not set a auto incremental id will be used which is unique for the worker.
      Parameters:
      processId - process id
      Returns:
      builder instance
      Throws:
      IllegalStateException - when the id is larger than the max id or smaller than 0
    • withCustomEpoch

      public SnowflakeCreatorBuilder withCustomEpoch(long customEpoch)
      Sets a custom offset for the epoch millis.

      Default is the January 1, 2015 Midnight UTC = 2015-01-01T00:00:00Z

      Parameters:
      customEpoch - custom offset.
      Returns:
      builder instance
    • withCustomEpoch

      public SnowflakeCreatorBuilder withCustomEpoch(ZonedDateTime offset)
      Sets a custom offset for the epoch millis.

      Default is the January 1, 2015 Midnight UTC = 2015-01-01T00:00:00Z

      Parameters:
      offset - custom offset.
      Returns:
      builder instance
    • withCustomEpoch

      public SnowflakeCreatorBuilder withCustomEpoch(Instant offset)
      Sets a custom offset for the epoch millis.

      Default is the January 1, 2015 Midnight UTC = 2015-01-01T00:00:00Z

      Parameters:
      offset - custom offset.
      Returns:
      builder instance
    • build

      public SnowflakeCreator build()