Class DatafakerStringGenerator
- All Implemented Interfaces:
DataGenerator<String>
Produces a realistic
String value from a Datafaker
provider — an email, a name, a phone number, an address part, and so on. The provider is supplied as
a Function<Faker, String> by DatafakerGeneratorPlugin.
Reproducibility. Datafaker needs a Random; this generator seeds one from
the engine's column-seeded RandomGenerator, so the same base seed yields the same realistic
values on every run. reseed(long) rebuilds the Faker so the output stays
deterministic under foreign-key wraparound and intra-table partitioning too. The Locale is
fixed (not the JVM default) so output is identical across machines.
If the produced value is longer than the column's declared size it is truncated, so locale-specific
output cannot overflow a VARCHAR(n).
- Since:
- 2.11.0
-
Field Summary
Fields inherited from class AbstractDataGenerator
random, randomUtils -
Constructor Summary
ConstructorsConstructorDescriptionDatafakerStringGenerator(RandomGenerator random, Locale locale, Integer maxSize, Function<net.datafaker.Faker, String> valueFunction) Creates a generator that draws realistic values from the given Datafaker provider. -
Method Summary
Modifier and TypeMethodDescriptiongenerate()Generates a random value of type T.Retrieves a value from a ResultSet column.voidreseed(long seed) Resets only the random source, replacingAbstractDataGenerator.random(and itsAbstractDataGenerator.randomUtilsview) with a freshly seededRandomGenerator.Methods inherited from class AbstractDataGenerator
generateAndSet, generateAsString, set
-
Constructor Details
-
DatafakerStringGenerator
public DatafakerStringGenerator(RandomGenerator random, Locale locale, Integer maxSize, Function<net.datafaker.Faker, String> valueFunction) Creates a generator that draws realistic values from the given Datafaker provider.- Parameters:
random- the engine-supplied, column-seeded random sourcelocale- the locale for realistic values (fixed for reproducibility)maxSize- the column's max length, or null/0 for unbounded; longer values are truncatedvalueFunction- the Datafaker provider to draw from
-
-
Method Details
-
generate
Description copied from interface:DataGeneratorGenerates a random value of type T.- Returns:
- a generated value, may be null if the generator supports nullable columns
-
reseed
public void reseed(long seed) Description copied from class:AbstractDataGeneratorResets only the random source, replacingAbstractDataGenerator.random(and itsAbstractDataGenerator.randomUtilsview) with a freshly seededRandomGenerator. Any counter or sequence state held by a subclass is intentionally left untouched, mirroring the legacyRandom.setSeedbehavior the engine relied on for foreign-key wraparound — only the random draws replay, not the generator's own progression.- Specified by:
reseedin interfaceDataGenerator<String>- Overrides:
reseedin classAbstractDataGenerator<String>- Parameters:
seed- the seed for the replacement generator
-
get
Description copied from interface:DataGeneratorRetrieves a value from a ResultSet column.- Parameters:
resultSet- the result set to read fromcolumnIndex- the 1-based column index- Returns:
- the value from the result set, properly cast to type T
- Throws:
SQLException- if the database operation fails
-