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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAllow aDurationof length zero to be generated.Returns the public API method name of the generator spec.max(long amount, TemporalUnit unit) Generate aDurationless than or equal to the specified amount.min(long amount, TemporalUnit unit) Generate aDurationgreater than or equal to the specified amount.nullable()Indicates thatnullvalue can be generated.of(long minAmount, long maxAmount, TemporalUnit unit) Generate aDurationin the given range, measured in specified units.protected DurationtryGenerateNonNull(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:AbstractGeneratorReturns the public API method name of the generator spec. The returned name is used for reporting validation errors.- Specified by:
apiMethodin classAbstractGenerator<Duration>- Returns:
- spec name if defined, or
nullotherwise
-
min
Description copied from interface:DurationGeneratorSpecGenerate aDurationgreater than or equal to the specified amount.- Specified by:
minin interfaceDurationGeneratorSpec- Specified by:
minin interfaceDurationSpec- Parameters:
amount- minimum duration amount (inclusive)unit- unit the amount is measured in- Returns:
- spec builder
-
max
Description copied from interface:DurationGeneratorSpecGenerate aDurationless than or equal to the specified amount.- Specified by:
maxin interfaceDurationGeneratorSpec- Specified by:
maxin interfaceDurationSpec- Parameters:
amount- maximum duration amount (inclusive)unit- unit the amount is measured in- Returns:
- spec builder
-
of
Description copied from interface:DurationGeneratorSpecGenerate aDurationin the given range, measured in specified units.- Specified by:
ofin interfaceDurationGeneratorSpec- Specified by:
ofin 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:DurationGeneratorSpecAllow aDurationof length zero to be generated.- Specified by:
allowZeroin interfaceDurationGeneratorSpec- Specified by:
allowZeroin interfaceDurationSpec- Returns:
- spec builder
-
nullable
Description copied from interface:NullableGeneratorSpecIndicates thatnullvalue can be generated.- Specified by:
nullablein interfaceNullableGeneratorSpec<Duration>- Specified by:
nullablein interfaceValueSpec<Duration>- Overrides:
nullablein classAbstractGenerator<Duration>- Returns:
- spec builder
-
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<Duration>- Parameters:
random- for generating the value- Returns:
- generated value, either a null or non-null
-