public class BigDecimalGenerator extends DecimalGenerator<BigDecimal>
Produces values of type BigDecimal
.
With no additional configuration, the generated values are chosen from
a range with a magnitude decided by
GenerationStatus.size()
.
Constructor and Description |
---|
BigDecimalGenerator() |
Modifier and Type | Method and Description |
---|---|
void |
configure(InRange range)
|
void |
configure(Precision configuration)
Tells this generator to produce values that have a specified
scale.
|
BigDecimal |
generate(SourceOfRandomness random,
GenerationStatus status) |
protected Predicate<BigDecimal> |
inRange() |
protected BigDecimal |
leastMagnitude() |
protected Function<BigDecimal,BigDecimal> |
narrow() |
protected BigDecimal |
negate(BigDecimal target) |
protected boolean |
negative(BigDecimal target) |
protected Function<BigDecimal,BigDecimal> |
widen() |
doShrink
addComponentGenerators, canGenerateForParametersOfTypes, canRegisterAsType, canShrink, compatibleWithTypeParameter, configurationAnnotationsOn, configure, configure, gen, hasComponents, narrow, numberOfNeededComponents, provide, shrink, types
public void configure(InRange range)
Tells this generator to produce values within a specified minimum (inclusive) and/or maximum (exclusive), with uniform distribution.
If an endpoint of the range is not specified, its value takes on
a magnitude influenced by
GenerationStatus.size()
.
range
- annotation that gives the range's constraintspublic void configure(Precision configuration)
Tells this generator to produce values that have a specified scale.
With no precision constraint and no min/max constraint, the scale of the generated values is unspecified.
Otherwise, the scale of the generated values is set as
max(0, precision.scale, range.min.scale, range.max.scale)
.
configuration
- annotation that gives the desired scale of the
generated valuespublic BigDecimal generate(SourceOfRandomness random, GenerationStatus status)
protected Function<BigDecimal,BigDecimal> widen()
widen
in class DecimalGenerator<BigDecimal>
protected Function<BigDecimal,BigDecimal> narrow()
narrow
in class DecimalGenerator<BigDecimal>
protected Predicate<BigDecimal> inRange()
inRange
in class DecimalGenerator<BigDecimal>
protected BigDecimal leastMagnitude()
leastMagnitude
in class DecimalGenerator<BigDecimal>
protected boolean negative(BigDecimal target)
negative
in class DecimalGenerator<BigDecimal>
protected BigDecimal negate(BigDecimal target)
negate
in class DecimalGenerator<BigDecimal>
© Copyright 2010-2016 Paul R. Holser, Jr. All rights reserved. Licensed under The MIT License. pholser@alumni.rice.edu