Package org.instancio.generator.specs
Interface NumberGeneratorSpec<T extends Number>
- Type Parameters:
T- type of number
- All Superinterfaces:
GeneratorSpec<T>,NullableGeneratorSpec<T>
- All Known Subinterfaces:
BigDecimalAsGeneratorSpec,BigDecimalGeneratorSpec,BigDecimalSpec,BigIntegerSpec,ByteSpec,DoubleSpec,FloatSpec,IntegerSpec,LongSpec,NumberAsGeneratorSpec<T>,NumberSpec<T>,ShortSpec
- All Known Implementing Classes:
AbstractRandomComparableNumberGeneratorSpec,AbstractRandomNumberGeneratorSpec,AtomicIntegerGenerator,AtomicLongGenerator,BigDecimalGenerator,BigIntegerGenerator,ByteGenerator,DoubleGenerator,FloatGenerator,IntegerGenerator,LongGenerator,ShortGenerator
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 the generated number.
-
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 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)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
-