Class SequentialIntegerGenerator.Builder

java.lang.Object
io.bloviate.gen.AbstractBuilder<Integer>
io.bloviate.gen.SequentialIntegerGenerator.Builder
All Implemented Interfaces:
Builder<Integer>
Enclosing class:
SequentialIntegerGenerator

public static class SequentialIntegerGenerator.Builder extends AbstractBuilder<Integer>
Fluent builder for SequentialIntegerGenerator.
  • Constructor Details

    • Builder

      public Builder(RandomGenerator random)
      Creates a builder backed by the given seeded random source.
      Parameters:
      random - the random source used to draw generated values
  • Method Details

    • start

      public SequentialIntegerGenerator.Builder start(int start)
      The first value of the sequence, inclusive. It is the value emitted for row 0 and the value the sequence wraps back to after end is emitted. Defaults to 1.
      Parameters:
      start - the lowest value of the cycle, inclusive
      Returns:
      this builder, for chaining
    • end

      public SequentialIntegerGenerator.Builder end(int end)
      The last value of the sequence, inclusive. Once end is emitted the next call wraps back to start, so the generator cycles through [start, end] forever. Defaults to Integer.MAX_VALUE. Must be >= start, otherwise build() throws.
      Parameters:
      end - the highest value of the cycle, inclusive
      Returns:
      this builder, for chaining
    • build

      Builds the generator.
      Returns:
      a new SequentialIntegerGenerator over the inclusive range [start, end]
      Throws:
      IllegalArgumentException - if end < start