Class ShortGenerator
java.lang.Object
org.instancio.internal.generator.AbstractGenerator<T>
org.instancio.internal.generator.lang.AbstractRandomNumberGeneratorSpec<T>
org.instancio.internal.generator.lang.AbstractRandomComparableNumberGeneratorSpec<Short>
org.instancio.internal.generator.lang.ShortGenerator
- All Implemented Interfaces:
AsStringGeneratorSpec<Short>,Generator<Short>,GeneratorSpec<Short>,AsGeneratorSpec<Short>,NullableGeneratorSpec<Short>,NumberAsGeneratorSpec<Short>,NumberGeneratorSpec<Short>,NumberSpec<Short>,ShortSpec,ValueSpec<Short>
public class ShortGenerator
extends AbstractRandomComparableNumberGeneratorSpec<Short>
implements ShortSpec
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the public API method name of the generator spec.Specifies the upper bound.Specifies the lower bound.nullable()Indicates thatnullvalue can be generated.nullable(boolean isNullable) Specifies the range for the generated number.protected ShorttryGenerateNonNull(Random random) Makes the best effort to return a non-null value.Methods inherited from class org.instancio.internal.generator.lang.AbstractRandomNumberGeneratorSpec
generate, getMax, getMinMethods inherited from class org.instancio.internal.generator.AbstractGenerator
getContext, hints, isNullableMethods 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
-
ShortGenerator
public ShortGenerator() -
ShortGenerator
-
-
Method Details
-
apiMethod
Description copied from class:AbstractGeneratorReturns the public API method name of the generator spec. The returned name is used for reporting validation errors.- Specified by:
apiMethodin classAbstractGenerator<Short>- Returns:
- spec name if defined, or
nullotherwise
-
min
Description copied from class:AbstractRandomComparableNumberGeneratorSpecSpecifies 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<Short>- Specified by:
minin interfaceNumberGeneratorSpec<Short>- Specified by:
minin interfaceNumberSpec<Short>- Specified by:
minin interfaceShortSpec- Overrides:
minin classAbstractRandomComparableNumberGeneratorSpec<Short>- Parameters:
min- lower bound (inclusive)- Returns:
- spec builder
-
max
Description copied from class:AbstractRandomComparableNumberGeneratorSpecSpecifies 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<Short>- Specified by:
maxin interfaceNumberGeneratorSpec<Short>- Specified by:
maxin interfaceNumberSpec<Short>- Specified by:
maxin interfaceShortSpec- Overrides:
maxin classAbstractRandomComparableNumberGeneratorSpec<Short>- 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<Short>- Specified by:
rangein interfaceNumberGeneratorSpec<Short>- Specified by:
rangein interfaceNumberSpec<Short>- Specified by:
rangein interfaceShortSpec- Overrides:
rangein classAbstractRandomComparableNumberGeneratorSpec<Short>- Parameters:
min- lower bound (inclusive)max- upper bound (inclusive)- Returns:
- spec builder
-
nullable
Description copied from interface:NullableGeneratorSpecIndicates thatnullvalue can be generated.- Specified by:
nullablein interfaceNullableGeneratorSpec<Short>- Specified by:
nullablein interfaceNumberAsGeneratorSpec<Short>- Specified by:
nullablein interfaceNumberGeneratorSpec<Short>- Specified by:
nullablein interfaceNumberSpec<Short>- Specified by:
nullablein interfaceShortSpec- Specified by:
nullablein interfaceValueSpec<Short>- Overrides:
nullablein classAbstractRandomNumberGeneratorSpec<Short>- Returns:
- spec builder
-
nullable
- Overrides:
nullablein classAbstractRandomNumberGeneratorSpec<Short>
-
tryGenerateNonNull
Description copied from class:AbstractGeneratorMakes the best effort to return a non-null value. However, in certain cases this method will produce anull.- Specified by:
tryGenerateNonNullin classAbstractGenerator<Short>- Parameters:
random- for generating the value- Returns:
- generated value, either a null or non-null
-