Package org.instancio.generator.specs
Interface NumberGeneratorSpec<T extends Number>
- Type Parameters:
T- type of number
- All Superinterfaces:
AsGeneratorSpec<T>,GeneratorSpec<T>,NullableGeneratorSpec<T>
- All Known Subinterfaces:
BigDecimalGeneratorSpec,BigDecimalSpec,BigIntegerSpec,ByteSpec,DoubleSpec,FloatSpec,IntegerSpec,LongSpec,NumberSpec<T>,ShortSpec
public interface NumberGeneratorSpec<T extends Number>
extends AsGeneratorSpec<T>, NullableGeneratorSpec<T>
Generator spec for numeric types.
- Since:
- 1.0.1
-
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
Specifies the lower bound.- Parameters:
min- lower bound (inclusive)- Returns:
- spec builder
- Since:
- 1.0.1
-
max
Specifies the upper bound.- Parameters:
max- upper bound (inclusive)- Returns:
- spec builder
- Since:
- 1.0.1
-
range
Specifies 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)min(Number)andmax(Number). For example, the following will generate a number within[1, 5]:ints().range(1, 5).min(95).max(99)- Parameters:
min- lower bound (inclusive)max- upper bound (inclusive)- Returns:
- spec builder
- Since:
- 1.1.2
-
nullable
NumberGeneratorSpec<T> nullable()Specifies that anullcan be generated.- Specified by:
nullablein interfaceNullableGeneratorSpec<T extends Number>- Returns:
- spec builder
- Since:
- 1.0.1
-