Interface BigDecimalSpec
- All Superinterfaces:
BigDecimalGeneratorSpec,GeneratorSpec<BigDecimal>,NullableGeneratorSpec<BigDecimal>,NumberGeneratorSpec<BigDecimal>,ValueSpec<BigDecimal>
BigDecimal values.- Since:
- 2.6.0
-
Method Summary
Modifier and TypeMethodDescriptionmax(BigDecimal max) Specifies the upper bound.min(BigDecimal min) Specifies the lower bound.nullable()Specifies that anullvalue can be generatedprecision(int precision) Precision of the generatedBigDecimal.range(BigDecimal min, BigDecimal max) Specifies the range for generated numbers.scale(int scale) Scale of the generatedBigDecimal.
-
Method Details
-
min
Specifies the lower bound.Note that this method is incompatible with
BigDecimalGeneratorSpec.precision(int). For details, seeBigDecimalGeneratorSpec.precision(int)javadoc.Note that this method is incompatible with
precision(int). For details, seeprecision(int)javadoc.- Specified by:
minin interfaceBigDecimalGeneratorSpec- Specified by:
minin interfaceNumberGeneratorSpec<BigDecimal>- Parameters:
min- lower bound (inclusive)- Returns:
- spec builder
-
max
Specifies the upper bound.Note that this method is incompatible with
BigDecimalGeneratorSpec.precision(int). For details, seeBigDecimalGeneratorSpec.precision(int)javadoc.Note that this method is incompatible with
precision(int). For details, seeprecision(int)javadoc.- Specified by:
maxin interfaceBigDecimalGeneratorSpec- Specified by:
maxin interfaceNumberGeneratorSpec<BigDecimal>- Parameters:
max- upper bound (inclusive)- Returns:
- spec builder
-
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)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)Note that this method is incompatible with
BigDecimalGeneratorSpec.precision(int). For details, seeBigDecimalGeneratorSpec.precision(int)javadoc.Note that this method is incompatible with
precision(int). For details, seeprecision(int)javadoc.- Specified by:
rangein interfaceBigDecimalGeneratorSpec- Specified by:
rangein interfaceNumberGeneratorSpec<BigDecimal>- Parameters:
min- lower bound (inclusive)max- upper bound (inclusive)- Returns:
- spec builder
-
nullable
BigDecimalSpec nullable()Description copied from interface:ValueSpecSpecifies that anullvalue can be generated- Specified by:
nullablein interfaceBigDecimalGeneratorSpec- Specified by:
nullablein interfaceNullableGeneratorSpec<BigDecimal>- Specified by:
nullablein interfaceNumberGeneratorSpec<BigDecimal>- Specified by:
nullablein interfaceValueSpec<BigDecimal>- Returns:
- spec builder reference
-
scale
Description copied from interface:BigDecimalGeneratorSpecScale of the generatedBigDecimal. Generated values will have givenscaleas returned byBigDecimal.scale().If not specified, the default scale is
2.- Specified by:
scalein interfaceBigDecimalGeneratorSpec- Parameters:
scale- the scale of generatedBigDecimalvalues- Returns:
- spec builder
-
precision
Precision of the generatedBigDecimal. Generated values will have givenprecisionas returned byBigDecimal.precision().This method is incompatible with the following methods:
BigDecimalGeneratorSpec.min(BigDecimal)BigDecimalGeneratorSpec.min(BigDecimal)BigDecimalGeneratorSpec.range(BigDecimal, BigDecimal)
If this method is combined with any of the above, the last method takes precedence.
// Example 1: range() takes precedence as it is specified last BigDecimal result = Gen.math().bigDecimal() .precision(5) .range(BigDecimal.ZERO, BigDecimal.ONE) .get(); // Sample output: 0.81 // Example 2: precision() takes precedence as it is specified last BigDecimal result = Gen.math().bigDecimal() .range(BigDecimal.ZERO, BigDecimal.ONE) .precision(5) .get(); // Sample output: 394.19- Specified by:
precisionin interfaceBigDecimalGeneratorSpec- Parameters:
precision- the precision of generatedBigDecimalvalues- Returns:
- spec builder
- Since:
- 3.3.0
-