Class MapGeneratorSpecImpl<K,V>
- java.lang.Object
-
- org.instancio.generators.AbstractRandomGenerator<Map<K,V>>
-
- org.instancio.generators.collections.MapGenerator<K,V>
-
- org.instancio.generators.collections.MapGeneratorSpecImpl<K,V>
-
- All Implemented Interfaces:
Generator<Map<K,V>>
,MapGeneratorSpec<K,V>
,GeneratorSpec<Map<K,V>>
public class MapGeneratorSpecImpl<K,V> extends MapGenerator<K,V>
-
-
Field Summary
-
Fields inherited from class org.instancio.generators.collections.MapGenerator
maxSize, minSize, nullable, nullableKeys, nullableValues, type
-
-
Constructor Summary
Constructors Constructor Description MapGeneratorSpecImpl(GeneratorContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<K,V>
generate()
Depending on implementation, repeated invocations may return different values.boolean
isDelegating()
Iftrue
, then this generator delegate object instantiation to another generator supplied viaGenerator.setDelegate(Generator)
.void
setDelegate(Generator<?> delegate)
Set a delegate that will be responsible for instantiating an object on behalf of this generator.Class<?>
targetType()
-
Methods inherited from class org.instancio.generators.collections.MapGenerator
getHints, maxSize, minSize, nullable, nullableKeys, nullableValues, type
-
Methods inherited from class org.instancio.generators.AbstractRandomGenerator
getContext, random
-
-
-
-
Constructor Detail
-
MapGeneratorSpecImpl
public MapGeneratorSpecImpl(GeneratorContext context)
-
-
Method Detail
-
generate
public Map<K,V> generate()
Description copied from interface:Generator
Depending on implementation, repeated invocations may return different values. Some implementations may return random values on each invocation, while others may return predefined values or random values from a given set.Generators can be passed in as a lambda function. The following example shows how to override generation strategy for certain fields.
Person person = Instancio.of(Person.class) .generate(field("age"), gen -> gen.oneOf(20, 30, 40, 50)) .supply(field("location"), () -> "Canada") .supply(all(LocalDateTime.class), () -> LocalDateTime.now()) .create();
-
isDelegating
public boolean isDelegating()
Description copied from interface:Generator
Iftrue
, then this generator delegate object instantiation to another generator supplied viaGenerator.setDelegate(Generator)
.- Returns:
true
if this is a delegating generator
-
setDelegate
public void setDelegate(Generator<?> delegate)
Description copied from interface:Generator
Set a delegate that will be responsible for instantiating an object on behalf of this generator.- Parameters:
delegate
- that will create the target object
-
targetType
public Class<?> targetType()
-
-