Class GroupedPrefixGenerator.Builder<T>

java.lang.Object
io.bloviate.gen.AbstractBuilder<T>
io.bloviate.gen.GroupedPrefixGenerator.Builder<T>
Type Parameters:
T - the Java type produced by the wrapped delegate
All Implemented Interfaces:
Builder<T>
Enclosing class:
GroupedPrefixGenerator<T>

public static class GroupedPrefixGenerator.Builder<T> extends AbstractBuilder<T>
  • Constructor Details

    • Builder

      public Builder(RandomGenerator random)
      Creates a builder.
      Parameters:
      random - the random source (the wrapped delegate may use it)
  • Method Details

    • groupSize

      public GroupedPrefixGenerator.Builder<T> groupSize(int groupSize)
      The size of each consecutive group of rows; the sparse-prefix pattern repeats every groupSize rows. A row's position within its group is rowIndex % groupSize; positions below prefixSize get a value, the rest are null. Must be >= 1, otherwise build() throws. Defaults to 1.
      Parameters:
      groupSize - the number of rows per group; must be >= 1
      Returns:
      this builder, for chaining
    • prefixSize

      public GroupedPrefixGenerator.Builder<T> prefixSize(int prefixSize)
      How many rows at the start of each group receive a (non-null) value from the delegate; the remaining groupSize - prefixSize rows emit SQL NULL. So prefixSize = 0 makes the whole column null and prefixSize = groupSize makes it fully populated. Must be in [0, groupSize], otherwise build() throws. Defaults to 0.
      Parameters:
      prefixSize - the number of leading non-null rows per group; must be in [0, groupSize]
      Returns:
      this builder, for chaining
    • delegate

      public GroupedPrefixGenerator.Builder<T> delegate(DataGenerator<T> delegate)
      The wrapped generator that supplies the value for each prefix (non-null) row; it is consulted only on prefix rows, never for the null tail, so a stateless delegate is recommended. Required — build() throws if left unset.
      Parameters:
      delegate - the generator producing the non-null prefix values
      Returns:
      this builder, for chaining
    • build

      public GroupedPrefixGenerator<T> build()
      Builds the generator.
      Returns:
      a new GroupedPrefixGenerator
      Throws:
      IllegalArgumentException - if groupSize < 1 or prefixSize is not in [0, groupSize]
      IllegalStateException - if no delegate was set