Package org.instancio.generator.util
Class CollectionGeneratorSpecImpl<T>
- java.lang.Object
-
- org.instancio.generator.AbstractRandomGenerator<Collection<T>>
-
- org.instancio.generator.util.CollectionGenerator<T>
-
- org.instancio.generator.util.CollectionGeneratorSpecImpl<T>
-
- All Implemented Interfaces:
Generator<Collection<T>>
,GeneratorSpec<Collection<T>>
,CollectionGeneratorSpec<T>
public class CollectionGeneratorSpecImpl<T> extends CollectionGenerator<T>
-
-
Field Summary
-
Fields inherited from class org.instancio.generator.util.CollectionGenerator
maxSize, minSize, nullable, nullableElements, type
-
-
Constructor Summary
Constructors Constructor Description CollectionGeneratorSpecImpl(GeneratorContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<T>
generate()
Returns a generated value.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.Optional<Class<?>>
targetClass()
Target class to generate.-
Methods inherited from class org.instancio.generator.util.CollectionGenerator
getHints, maxSize, minSize, nullable, nullableElements, size, type
-
Methods inherited from class org.instancio.generator.AbstractRandomGenerator
getContext, random
-
-
-
-
Constructor Detail
-
CollectionGeneratorSpecImpl
public CollectionGeneratorSpecImpl(GeneratorContext context)
-
-
Method Detail
-
generate
public Collection<T> generate()
Description copied from interface:Generator
Returns a generated value. By default, generated values are random.Generation parameters for common types such as strings, numbers, collections, etc. can be customised by passing in custom generators.
-
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
-
targetClass
public Optional<Class<?>> targetClass()
Description copied from interface:Generator
Target class to generate.If
Optional.empty()
is returned, it will default to the field type for fields, and element type for collection and array elements.If the type is an interface, such as
Set
, will generate a default implementation class such asHashSet
.- Returns:
- target class
-
-