Class DatafakerGeneratorPlugin
- All Implemented Interfaces:
GeneratorPlugin
GeneratorPlugin that maps common column names to realistic
Datafaker providers, so an email VARCHAR gets a
plausible email instead of random text. This is the opt-in semantic-data layer (issue #472).
Opt-in, twice over. Nothing changes unless you (a) put bloviate-datafaker
on the classpath and (b) build a GeneratorRegistry that includes this plugin — either via
GeneratorRegistry.Builder.discover() (it is registered as a ServiceLoader
provider) or explicitly with GeneratorRegistry.Builder.register(GeneratorPlugin). The
registry is consulted between per-column overrides and the built-in DatabaseSupport
defaults, which remain the fallback for every unmatched column.
Safety defaults. Emails use Datafaker's reserved example.* domains and
phone numbers the reserved 555-01xx range, so generated identifiers never collide with real
ones. Values are truncated to the column's length. The locale is fixed (default Locale.ENGLISH)
for reproducible, charset-safe output; pass another locale to the DatafakerGeneratorPlugin(Locale)
constructor and register it explicitly if you need one.
Caveats. Realistic values are drawn from bounded dictionaries, so they can repeat
at high row counts — do not route UNIQUE/primary-key columns through this plugin (keep
Bloviate's sequence/seeded generators for those). Realistic generation is also slower than the
type-driven default, so it is best kept off the highest-throughput fills.
- Since:
- 2.11.0
-
Constructor Summary
ConstructorsConstructorDescriptionUsesLocale.ENGLISH; this is the constructor theServiceLoadercalls.DatafakerGeneratorPlugin(Locale locale) Creates a plugin that generates realistic values in the given locale. -
Method Summary
Modifier and TypeMethodDescriptionvoidcontribute(GeneratorRegistry.Builder builder) Contributes generator rules to the registry under construction.
-
Constructor Details
-
DatafakerGeneratorPlugin
public DatafakerGeneratorPlugin()UsesLocale.ENGLISH; this is the constructor theServiceLoadercalls. -
DatafakerGeneratorPlugin
Creates a plugin that generates realistic values in the given locale.- Parameters:
locale- the locale for realistic values; fixed (not the JVM default) for reproducibility
-
-
Method Details
-
contribute
Description copied from interface:GeneratorPluginContributes generator rules to the registry under construction.- Specified by:
contributein interfaceGeneratorPlugin- Parameters:
builder- the registry builder to register matchers on
-