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>
Builder for
GroupedPrefixGenerator.-
Field Summary
Fields inherited from class AbstractBuilder
DEFAULT_REFERENCE, random -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the generator.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.groupSize(int groupSize) The size of each consecutive group of rows; the sparse-prefix pattern repeats everygroupSizerows.prefixSize(int prefixSize) How many rows at the start of each group receive a (non-null) value from the delegate; the remaininggroupSize - prefixSizerows emit SQLNULL.
-
Constructor Details
-
Builder
Creates a builder.- Parameters:
random- the random source (the wrapped delegate may use it)
-
-
Method Details
-
groupSize
The size of each consecutive group of rows; the sparse-prefix pattern repeats everygroupSizerows. A row's position within its group isrowIndex % groupSize; positions belowprefixSizeget a value, the rest arenull. Must be>= 1, otherwisebuild()throws. Defaults to1.- Parameters:
groupSize- the number of rows per group; must be>= 1- Returns:
- this builder, for chaining
-
prefixSize
How many rows at the start of each group receive a (non-null) value from the delegate; the remaininggroupSize - prefixSizerows emit SQLNULL. SoprefixSize = 0makes the whole column null andprefixSize = groupSizemakes it fully populated. Must be in[0, groupSize], otherwisebuild()throws. Defaults to0.- Parameters:
prefixSize- the number of leading non-null rows per group; must be in[0, groupSize]- Returns:
- this builder, for chaining
-
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
Builds the generator.- Returns:
- a new
GroupedPrefixGenerator - Throws:
IllegalArgumentException- ifgroupSize < 1orprefixSizeis not in[0, groupSize]IllegalStateException- if nodelegatewas set
-