Package org.instancio.generator.specs
Interface NumberAsGeneratorSpec<T extends Number>
- All Superinterfaces:
AsGeneratorSpec<T>,GeneratorSpec<T>,NullableGeneratorSpec<T>,NumberGeneratorSpec<T>
public interface NumberAsGeneratorSpec<T extends Number>
extends NumberGeneratorSpec<T>, AsGeneratorSpec<T>
Generator spec for
Number types
that supports AsGeneratorSpec.- Since:
- 2.6.0
-
Method Summary
Modifier and TypeMethodDescriptionSpecifies the upper bound.Specifies the lower bound.nullable()Specifies that anullcan be generated.Specifies the range for generated numbers.Methods inherited from interface org.instancio.generator.specs.AsGeneratorSpec
as, asString
-
Method Details
-
min
Description copied from interface:NumberGeneratorSpecSpecifies the lower bound.- 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 interfaceNumberGeneratorSpec<T extends Number>- Parameters:
max- upper bound (inclusive)- Returns:
- spec builder
-
range
Description copied from interface:NumberGeneratorSpecSpecifies the range for generated numbers.The following examples use
int, however the same principle applies to all numeric types, includingBigIntegerandBigDecimal.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 interfaceNumberGeneratorSpec<T extends Number>- Parameters:
min- lower bound (inclusive)max- upper bound (inclusive)- Returns:
- spec builder
-
nullable
NumberAsGeneratorSpec<T> nullable()Description copied from interface:NumberGeneratorSpecSpecifies that anullcan be generated.- Specified by:
nullablein interfaceNullableGeneratorSpec<T extends Number>- Specified by:
nullablein interfaceNumberGeneratorSpec<T extends Number>- Returns:
- spec builder
-