Class ChildKeyComponentGenerator.Builder

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

public static class ChildKeyComponentGenerator.Builder extends AbstractBuilder<Integer>
  • Constructor Details

    • Builder

      public Builder(RandomGenerator random)
      Creates a builder.
      Parameters:
      random - the random source (unused by this generator, but required by the contract)
  • Method Details

    • cardinality

      public ChildKeyComponentGenerator.Builder cardinality(ChildCardinality cardinality)
      The ChildCardinality that supplies each parent's child count. This drives the walk over parents in both modes, so it must be the same ChildCardinality instance shared with this child table's other component generators and with the parent table's ChildCountGenerator; otherwise the parent keys, sequence numbers, and declared child counts will not line up. Required — build() throws if left unset.
      Parameters:
      cardinality - the shared per-parent child-count source
      Returns:
      this builder, for chaining
    • sequence

      Switches this generator into sequence mode: it emits the child's 1-based sequence number within its parent (start + positionWithinParent, so start = 1 yields 1, 2, 3, ...). Use this for the trailing sequence column of the child key. Mutually exclusive with the parent-component mode configured via repeat(long)/ cycle(int) (which is the default when sequence() is not called); in that mode the generator instead reproduces one dimension of the parent's key.
      Returns:
      this builder, for chaining
    • start

      public ChildKeyComponentGenerator.Builder start(int start)
      The base value, inclusive. In sequence mode it is the number of the first child within each parent (start = 1 yields 1, 2, 3, ...); in parent-component mode it is the start term of start + ((parentIndex / repeat) % cycle) and must match the corresponding parent start. Defaults to 1.
      Parameters:
      start - the first value of the sequence or parent dimension, inclusive
      Returns:
      this builder, for chaining
    • repeat

      public ChildKeyComponentGenerator.Builder repeat(long repeat)
      For a parent-component generator (i.e. when sequence() is not used), the number of consecutive parents that share this dimension's value — i.e. the product of the sizes of all parent dimensions nested inside this one (mirrors CompositeKeyComponentGenerator, and must match the parent's own repeat). The repeat term in start + ((parentIndex / repeat) % cycle). Ignored in sequence mode. Defaults to 1.
      Parameters:
      repeat - the number of consecutive parents per value (product of inner parent dimension sizes)
      Returns:
      this builder, for chaining
    • cycle

      public ChildKeyComponentGenerator.Builder cycle(int cycle)
      For a parent-component generator (i.e. when sequence() is not used), the size (cardinality) of this parent dimension — the cycle term in start + ((parentIndex / repeat) % cycle), which must match the parent's own cycle. Ignored in sequence mode. Defaults to 1.
      Parameters:
      cycle - the number of distinct values (size) of this parent dimension
      Returns:
      this builder, for chaining
    • build

      Builds the generator.
      Returns:
      a new ChildKeyComponentGenerator
      Throws:
      IllegalStateException - if no cardinality was set