Package org.instancio.generator
Interface Generator<T>
- Type Parameters:
T- type to generate
- All Superinterfaces:
GeneratorSpec<T>
- All Known Implementing Classes:
AbstractGenerator,AbstractRandomComparableNumberGeneratorSpec,AbstractRandomNumberGeneratorSpec,ArrayGenerator,AtomicIntegerGenerator,AtomicLongGenerator,BigDecimalGenerator,BigIntegerGenerator,BooleanGenerator,ByteGenerator,CalendarGenerator,CharacterGenerator,CollectionGenerator,CollectionGeneratorSpecImpl,CreditCardNumberGenerator,CsvGenerator,DateGenerator,DoubleGenerator,DurationGenerator,EanGenerator,EmailGenerator,EmitGenerator,EnumGenerator,EnumSetGenerator,FileGenerator,FloatGenerator,GeneratorDecorator,HashGenerator,InetAddressGenerator,InstantGenerator,InstantiatingGenerator,IntegerGenerator,Ip4Generator,IsbnGenerator,LocalDateGenerator,LocalDateTimeGenerator,LocaleGenerator,LocalTimeGenerator,LongGenerator,LoremIpsumGenerator,LuhnGenerator,MapEntryGenerator,MapGenerator,MapGeneratorSpecImpl,MonthDayGenerator,OffsetDateTimeGenerator,OffsetTimeGenerator,OneOfArrayGenerator,OneOfCollectionGenerator,OptionalGenerator,PathGenerator,PeriodGenerator,ShortGenerator,SqlDateGenerator,StringBuilderGenerator,StringGenerator,SupplierAdapter,TextPatternGenerator,TimestampGenerator,URIGenerator,URLGenerator,UUIDGenerator,UUIDStringGenerator,XMLGregorianCalendarGenerator,YearGenerator,YearMonthGenerator,ZonedDateTimeGenerator,ZoneIdGenerator,ZoneOffsetGenerator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A class for generating values of a specific type.
- Since:
- 1.0.1
-
Method Summary
-
Method Details
-
generate
Returns a generated value.If this method produces random data, the data needs to be generated using the provided
Randominstance. This ensures generated values are reproducible for a given seed value.- Parameters:
random- provider for generating random values- Returns:
- generated value or
nullif value is nullable, could not be generated, or generation is delegated to the engine
-
hints
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
nullfields) - can be modified using selectors
For example, setting the hint to
AfterGenerate.POPULATE_NULLSwill cause Instancio to populatenullfields 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
AfterGeneratevalue configured in theSettingsusing the keyKeys.AFTER_GENERATE_HINT.In addition, the following hints can be provided for populating data structures:
- Returns:
- hints from this generator to the engine
- Since:
- 2.0.0
- See Also:
- should be populated (for example, if it has
-