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

public class DurationGenerator extends AbstractGenerator<Duration> implements DurationGeneratorSpec
  • Constructor Details

  • Method Details

    • of

      public DurationGeneratorSpec of(long minAmount, long maxAmount, TemporalUnit unit)
      Description copied from interface: DurationGeneratorSpec
      Generate a Duration in the given range, measured in specified units.
      Specified by:
      of in interface DurationGeneratorSpec
      Parameters:
      minAmount - minimum duration amount (inclusive)
      maxAmount - maximum duration amount (inclusive)
      unit - unit the duration is measured in
      Returns:
      spec builder
    • allowZero

      public DurationGeneratorSpec allowZero()
      Description copied from interface: DurationGeneratorSpec
      Allow a Duration of length zero to be generated.
      Specified by:
      allowZero in interface DurationGeneratorSpec
      Returns:
      spec builder
    • generate

      public Duration generate(Random random)
      Description copied from interface: Generator
      Returns a generated value.

      If this method produces random data, the data needs to be generated using the provided Random instance. This ensures generated values are reproducible for a given seed value.

      Specified by:
      generate in interface Generator<Duration>
      Parameters:
      random - provider for generating random values
      Returns:
      generated value or null if value is nullable, could not be generated, or generation is delegated to the engine