Class AbstractRandomComparableNumberGeneratorSpec<T extends Number & Comparable<T>>
java.lang.Object
org.instancio.internal.generator.AbstractGenerator<T>
org.instancio.internal.generator.lang.AbstractRandomNumberGeneratorSpec<T>
org.instancio.internal.generator.lang.AbstractRandomComparableNumberGeneratorSpec<T>
- All Implemented Interfaces:
AsStringGeneratorSpec<T>,Generator<T>,GeneratorSpec<T>,AsGeneratorSpec<T>,NullableGeneratorSpec<T>,NumberAsGeneratorSpec<T>,NumberGeneratorSpec<T>
- Direct Known Subclasses:
BigDecimalGenerator,BigIntegerGenerator,ByteGenerator,DoubleGenerator,FloatGenerator,IntegerGenerator,LongGenerator,ShortGenerator
public abstract class AbstractRandomComparableNumberGeneratorSpec<T extends Number & Comparable<T>>
extends AbstractRandomNumberGeneratorSpec<T>
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractRandomComparableNumberGeneratorSpec(GeneratorContext context, T min, T max, boolean nullable) -
Method Summary
Modifier and TypeMethodDescriptionSpecifies the upper bound.Specifies the lower bound.Specifies the range for the generated number.Methods inherited from class org.instancio.internal.generator.lang.AbstractRandomNumberGeneratorSpec
generate, getMax, getMin, nullable, nullableMethods inherited from class org.instancio.internal.generator.AbstractGenerator
apiMethod, getContext, hints, isNullable, tryGenerateNonNullMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.instancio.generator.specs.AsGeneratorSpec
as, asStringMethods inherited from interface org.instancio.generator.AsStringGeneratorSpec
asString
-
Constructor Details
-
AbstractRandomComparableNumberGeneratorSpec
protected AbstractRandomComparableNumberGeneratorSpec(GeneratorContext context, T min, T max, boolean nullable)
-
-
Method Details
-
min
Specifies the lower bound.If the specified
minvalue is greater than or equal to the currentmaxvalue, themaxvalue will be updated to a value higher than the givenmin.- Specified by:
minin interfaceNumberAsGeneratorSpec<T extends Number & Comparable<T>>- Specified by:
minin interfaceNumberGeneratorSpec<T extends Number & Comparable<T>>- Overrides:
minin classAbstractRandomNumberGeneratorSpec<T extends Number & Comparable<T>>- Parameters:
min- lower bound (inclusive)- Returns:
- spec builder
-
max
Specifies the upper bound.If the specified
maxvalue is less than or equal to the currentminvalue, theminvalue will be updated to a value lower than the givenmax.- Specified by:
maxin interfaceNumberAsGeneratorSpec<T extends Number & Comparable<T>>- Specified by:
maxin interfaceNumberGeneratorSpec<T extends Number & Comparable<T>>- Overrides:
maxin classAbstractRandomNumberGeneratorSpec<T extends Number & Comparable<T>>- Parameters:
max- upper bound (inclusive)- Returns:
- spec builder
-
range
Description copied from interface:NumberGeneratorSpecSpecifies 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)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 interfaceNumberAsGeneratorSpec<T extends Number & Comparable<T>>- Specified by:
rangein interfaceNumberGeneratorSpec<T extends Number & Comparable<T>>- Overrides:
rangein classAbstractRandomNumberGeneratorSpec<T extends Number & Comparable<T>>- Parameters:
min- lower bound (inclusive)max- upper bound (inclusive)- Returns:
- spec builder
-