Class OneOfCollectionGenerator<T>
java.lang.Object
org.instancio.internal.generator.AbstractGenerator<T>
org.instancio.internal.generator.util.OneOfCollectionGenerator<T>
- All Implemented Interfaces:
Generator<T>,GeneratorSpec<T>,NullableGeneratorSpec<T>,OneOfCollectionGeneratorSpec<T>,OneOfCollectionSpec<T>,ValueSpec<T>
public class OneOfCollectionGenerator<T>
extends AbstractGenerator<T>
implements OneOfCollectionSpec<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the public API method name of the generator spec.nullable()Indicates thatnullvalue can be generated.oneOf(Collection<T> values) Selects a random value from the given choices.tryGenerateNonNull(Random random) Makes the best effort to return a non-null value.Methods inherited from class org.instancio.internal.generator.AbstractGenerator
generate, getContext, hints, isNullable, nullableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.instancio.generator.specs.OneOfCollectionSpec
toModel
-
Constructor Details
-
OneOfCollectionGenerator
public OneOfCollectionGenerator() -
OneOfCollectionGenerator
-
-
Method Details
-
apiMethod
Description copied from class:AbstractGeneratorReturns the public API method name of the generator spec. The returned name is used for reporting validation errors.- Specified by:
apiMethodin classAbstractGenerator<T>- Returns:
- spec name if defined, or
nullotherwise
-
oneOf
Description copied from interface:OneOfCollectionGeneratorSpecSelects a random value from the given choices.- Specified by:
oneOfin interfaceOneOfCollectionGeneratorSpec<T>- Specified by:
oneOfin interfaceOneOfCollectionSpec<T>- Parameters:
values- from which a random value will be selected- Returns:
- completed spec with no further methods
-
nullable
Description copied from interface:NullableGeneratorSpecIndicates thatnullvalue can be generated.- Specified by:
nullablein interfaceNullableGeneratorSpec<T>- Specified by:
nullablein interfaceValueSpec<T>- Overrides:
nullablein classAbstractGenerator<T>- Returns:
- spec builder
-
tryGenerateNonNull
Description copied from class:AbstractGeneratorMakes the best effort to return a non-null value. However, in certain cases this method will produce anull.- Specified by:
tryGenerateNonNullin classAbstractGenerator<T>- Parameters:
random- for generating the value- Returns:
- generated value, either a null or non-null
-