Class OptionalGenerator<T>
java.lang.Object
org.instancio.internal.generator.AbstractGenerator<Optional<T>>
org.instancio.internal.generator.util.OptionalGenerator<T>
- All Implemented Interfaces:
Generator<Optional<T>>
,GeneratorSpec<Optional<T>>
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.instancio.internal.generator.AbstractGenerator
getContext
-
Constructor Details
-
OptionalGenerator
-
-
Method Details
-
generate
Description copied from interface:Generator
Returns a generated value.If this method produces random data, the data needs to be generated using the provided
Random
instance. This ensures generated values are reproducible for a given seed value.- Parameters:
random
- provider for generating random values- Returns:
- generated value or
null
if value is nullable, could not be generated, or generation is delegated to the engine
-
hints
Description copied from interface:Generator
Hints provided by the generator to the engine.The most important hint for custom generators is
AfterGenerate
. This hint indicates whether the object created by this generator:- should be populated (for example, if it has
null
fields) - can be modified using selectors
For example, setting the hint to
AfterGenerate.POPULATE_NULLS
will cause Instancio to populatenull
fields on the object returned by this generator:@Override public Hints hints() { return Hints.afterGenerate(AfterGenerate.POPULATE_NULLS); }
If the action is not specified, default behaviour will be based on the
AfterGenerate
value configured in theSettings
using the keyKeys.AFTER_GENERATE_HINT
.In addition, the following hints can be provided for populating data structures:
- should be populated (for example, if it has
-