Class DurationGenerator
java.lang.Object
org.instancio.internal.generator.AbstractGenerator<Duration>
org.instancio.internal.generator.time.DurationGenerator
- All Implemented Interfaces:
Generator<Duration>
,GeneratorSpec<Duration>
,DurationGeneratorSpec
,DurationSpec
,NullableGeneratorSpec<Duration>
,ValueSpec<Duration>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAllow aDuration
of length zero to be generated.Returns the public API method name of the generator spec.max
(long amount, TemporalUnit unit) Generate aDuration
less than or equal to the specified amount.min
(long amount, TemporalUnit unit) Generate aDuration
greater than or equal to the specified amount.nullable()
Indicates thatnull
value can be generated.of
(long minAmount, long maxAmount, TemporalUnit unit) Generate aDuration
in the given range, measured in specified units.protected Duration
tryGenerateNonNull
(Random random) Makes the best effort to return a non-null value.Methods inherited from class org.instancio.internal.generator.AbstractGenerator
generate, getContext, hints, isNullable, nullable
-
Constructor Details
-
DurationGenerator
public DurationGenerator() -
DurationGenerator
-
-
Method Details
-
apiMethod
Description copied from class:AbstractGenerator
Returns the public API method name of the generator spec. The returned name is used for reporting validation errors.- Specified by:
apiMethod
in classAbstractGenerator<Duration>
- Returns:
- spec name if defined, or
null
otherwise
-
min
Description copied from interface:DurationGeneratorSpec
Generate aDuration
greater than or equal to the specified amount.- Specified by:
min
in interfaceDurationGeneratorSpec
- Specified by:
min
in interfaceDurationSpec
- Parameters:
amount
- minimum duration amount (inclusive)unit
- unit the amount is measured in- Returns:
- spec builder
-
max
Description copied from interface:DurationGeneratorSpec
Generate aDuration
less than or equal to the specified amount.- Specified by:
max
in interfaceDurationGeneratorSpec
- Specified by:
max
in interfaceDurationSpec
- Parameters:
amount
- maximum duration amount (inclusive)unit
- unit the amount is measured in- Returns:
- spec builder
-
of
Description copied from interface:DurationGeneratorSpec
Generate aDuration
in the given range, measured in specified units.- Specified by:
of
in interfaceDurationGeneratorSpec
- Specified by:
of
in interfaceDurationSpec
- Parameters:
minAmount
- minimum duration amount (inclusive)maxAmount
- maximum duration amount (inclusive)unit
- unit the amount is measured in- Returns:
- spec builder
-
allowZero
Description copied from interface:DurationGeneratorSpec
Allow aDuration
of length zero to be generated.- Specified by:
allowZero
in interfaceDurationGeneratorSpec
- Specified by:
allowZero
in interfaceDurationSpec
- Returns:
- spec builder
-
nullable
Description copied from interface:NullableGeneratorSpec
Indicates thatnull
value can be generated.- Specified by:
nullable
in interfaceNullableGeneratorSpec<Duration>
- Specified by:
nullable
in interfaceValueSpec<Duration>
- Overrides:
nullable
in classAbstractGenerator<Duration>
- Returns:
- spec builder
-
tryGenerateNonNull
Description copied from class:AbstractGenerator
Makes the best effort to return a non-null value. However, in certain cases this method will produce anull
.- Specified by:
tryGenerateNonNull
in classAbstractGenerator<Duration>
- Parameters:
random
- for generating the value- Returns:
- generated value, either a null or non-null
-