Class BooleanGenerator
java.lang.Object
org.instancio.internal.generator.AbstractGenerator<Boolean>
org.instancio.internal.generator.lang.BooleanGenerator
- All Implemented Interfaces:
AsStringGeneratorSpec<Boolean>
,Generator<Boolean>
,GeneratorSpec<Boolean>
,AsGeneratorSpec<Boolean>
,BooleanAsGeneratorSpec
,BooleanGeneratorSpec
,BooleanSpec
,NullableGeneratorSpec<Boolean>
,ValueSpec<Boolean>
public class BooleanGenerator
extends AbstractGenerator<Boolean>
implements BooleanSpec, BooleanAsGeneratorSpec
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the public API method name of the generator spec.nullable()
Indicates thatnull
value can be generated.probability
(double probability) Specifies the probability of generatingtrue
.protected Boolean
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, nullable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.instancio.generator.specs.AsGeneratorSpec
as, asString
Methods inherited from interface org.instancio.generator.AsStringGeneratorSpec
asString
-
Constructor Details
-
BooleanGenerator
public BooleanGenerator() -
BooleanGenerator
-
-
Method Details
-
apiMethod
Description copied from class:AbstractGenerator
Returns the public API method name of the generator spec. The returned name is used for reporting validation errors.- Specified by:
apiMethod
in classAbstractGenerator<Boolean>
- Returns:
- spec name if defined, or
null
otherwise
-
probability
Description copied from interface:BooleanSpec
Specifies the probability of generatingtrue
.- Specified by:
probability
in interfaceBooleanAsGeneratorSpec
- Specified by:
probability
in interfaceBooleanGeneratorSpec
- Specified by:
probability
in interfaceBooleanSpec
- Parameters:
probability
- of generatingtrue
between 0 and 1 inclusive- Returns:
- spec builder
-
nullable
Description copied from interface:NullableGeneratorSpec
Indicates thatnull
value can be generated.- Specified by:
nullable
in interfaceBooleanAsGeneratorSpec
- Specified by:
nullable
in interfaceBooleanGeneratorSpec
- Specified by:
nullable
in interfaceBooleanSpec
- Specified by:
nullable
in interfaceNullableGeneratorSpec<Boolean>
- Specified by:
nullable
in interfaceValueSpec<Boolean>
- Overrides:
nullable
in classAbstractGenerator<Boolean>
- Returns:
- spec builder
-
tryGenerateNonNull
Description copied from class:AbstractGenerator
Makes the best effort to return a non-null value. However, in certain cases this method will produce anull
.- Specified by:
tryGenerateNonNull
in classAbstractGenerator<Boolean>
- Parameters:
random
- for generating the value- Returns:
- generated value, either a null or non-null
-