Class AbstractRandomNumberGeneratorSpec<T extends Number>
java.lang.Object
org.instancio.internal.generator.AbstractGenerator<T>
org.instancio.internal.generator.lang.AbstractRandomNumberGeneratorSpec<T>
- All Implemented Interfaces:
AsStringGeneratorSpec<T>,Generator<T>,GeneratorSpec<T>,AsGeneratorSpec<T>,NullableGeneratorSpec<T>,NumberAsGeneratorSpec<T>,NumberGeneratorSpec<T>
- Direct Known Subclasses:
AbstractRandomComparableNumberGeneratorSpec,AtomicIntegerGenerator,AtomicLongGenerator
public abstract class AbstractRandomNumberGeneratorSpec<T extends Number>
extends AbstractGenerator<T>
implements NumberAsGeneratorSpec<T>
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractRandomNumberGeneratorSpec(GeneratorContext context, T min, T max, boolean nullable) -
Method Summary
Modifier and TypeMethodDescriptionBase implementation that handles nullable values.protected final TgetMax()protected final TgetMin()Specifies the upper bound.Specifies the lower bound.nullable()Indicates thatnullvalue can be generated.nullable(boolean isNullable) Specifies the range for the generated number.Methods inherited from class org.instancio.internal.generator.AbstractGenerator
apiMethod, getContext, hints, isNullable, tryGenerateNonNullMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.instancio.generator.specs.AsGeneratorSpec
as, asStringMethods inherited from interface org.instancio.generator.AsStringGeneratorSpec
asString
-
Constructor Details
-
AbstractRandomNumberGeneratorSpec
protected AbstractRandomNumberGeneratorSpec(GeneratorContext context, T min, T max, boolean nullable)
-
-
Method Details
-
getMin
-
getMax
-
min
Description copied from interface:NumberGeneratorSpecSpecifies the lower bound.- Specified by:
minin interfaceNumberAsGeneratorSpec<T extends Number>- Specified by:
minin interfaceNumberGeneratorSpec<T extends Number>- Parameters:
min- lower bound (inclusive)- Returns:
- spec builder
-
max
Description copied from interface:NumberGeneratorSpecSpecifies the upper bound.- Specified by:
maxin interfaceNumberAsGeneratorSpec<T extends Number>- Specified by:
maxin interfaceNumberGeneratorSpec<T extends Number>- Parameters:
max- upper bound (inclusive)- Returns:
- spec builder
-
nullable
Description copied from interface:NullableGeneratorSpecIndicates thatnullvalue can be generated.- Specified by:
nullablein interfaceNullableGeneratorSpec<T extends Number>- Specified by:
nullablein interfaceNumberAsGeneratorSpec<T extends Number>- Specified by:
nullablein interfaceNumberGeneratorSpec<T extends Number>- Overrides:
nullablein classAbstractGenerator<T extends Number>- Returns:
- spec builder
-
nullable
- Overrides:
nullablein classAbstractGenerator<T extends Number>
-
range
Description copied from interface:NumberGeneratorSpecSpecifies the range for the generated number.This method can be invoked multiple times to specify several ranges, for example, the following will generate a random value within
[10-15]or[20-25]:
Note: this method has higher precedence thanints().range(10, 15).range(20, 25)NumberGeneratorSpec.min(Number)andNumberGeneratorSpec.max(Number). For example, the following will generate a number within[1, 5]:ints().range(1, 5).min(95).max(99)- Specified by:
rangein interfaceNumberAsGeneratorSpec<T extends Number>- Specified by:
rangein interfaceNumberGeneratorSpec<T extends Number>- Parameters:
min- lower bound (inclusive)max- upper bound (inclusive)- Returns:
- spec builder
-
generate
Description copied from class:AbstractGeneratorBase implementation that handles nullable values.
-