Class ChildKeyComponentGenerator.Builder
- Enclosing class:
ChildKeyComponentGenerator
Builder for
ChildKeyComponentGenerator.-
Field Summary
Fields inherited from class AbstractBuilder
DEFAULT_REFERENCE, random -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the generator.cardinality(ChildCardinality cardinality) TheChildCardinalitythat supplies each parent's child count.cycle(int cycle) For a parent-component generator (i.e. whensequence()is not used), the size (cardinality) of this parent dimension — thecycleterm instart + ((parentIndex / repeat) % cycle), which must match the parent's owncycle.repeat(long repeat) For a parent-component generator (i.e. whensequence()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 (mirrorsCompositeKeyComponentGenerator, and must match the parent's ownrepeat).sequence()Switches this generator into sequence mode: it emits the child's 1-based sequence number within its parent (start + positionWithinParent, sostart = 1yields1, 2, 3, ...).start(int start) The base value, inclusive.
-
Constructor Details
-
Builder
Creates a builder.- Parameters:
random- the random source (unused by this generator, but required by the contract)
-
-
Method Details
-
cardinality
TheChildCardinalitythat supplies each parent's child count. This drives the walk over parents in both modes, so it must be the sameChildCardinalityinstance shared with this child table's other component generators and with the parent table'sChildCountGenerator; 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, sostart = 1yields1, 2, 3, ...). Use this for the trailing sequence column of the child key. Mutually exclusive with the parent-component mode configured viarepeat(long)/cycle(int)(which is the default whensequence()is not called); in that mode the generator instead reproduces one dimension of the parent's key.- Returns:
- this builder, for chaining
-
start
The base value, inclusive. In sequence mode it is the number of the first child within each parent (start = 1yields1, 2, 3, ...); in parent-component mode it is thestartterm ofstart + ((parentIndex / repeat) % cycle)and must match the corresponding parentstart. Defaults to1.- Parameters:
start- the first value of the sequence or parent dimension, inclusive- Returns:
- this builder, for chaining
-
repeat
For a parent-component generator (i.e. whensequence()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 (mirrorsCompositeKeyComponentGenerator, and must match the parent's ownrepeat). Therepeatterm instart + ((parentIndex / repeat) % cycle). Ignored in sequence mode. Defaults to1.- Parameters:
repeat- the number of consecutive parents per value (product of inner parent dimension sizes)- Returns:
- this builder, for chaining
-
cycle
For a parent-component generator (i.e. whensequence()is not used), the size (cardinality) of this parent dimension — thecycleterm instart + ((parentIndex / repeat) % cycle), which must match the parent's owncycle. Ignored in sequence mode. Defaults to1.- 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 nocardinalitywas set
-