Class DurationGenerator

java.lang.Object
org.instancio.generator.time.DurationGenerator
All Implemented Interfaces:
Generator<Duration>, GeneratorSpec<Duration>, DurationGeneratorSpec

public class DurationGenerator extends Object implements Generator<Duration>, DurationGeneratorSpec
  • Constructor Details

    • DurationGenerator

      public DurationGenerator()
  • 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 the generated value is random, it needs to be generated using the given Random instance. This ensures the data is generated with the same seed value and allows random data to be reproduced by specifying the seed value.

      Specified by:
      generate in interface Generator<Duration>
      Parameters:
      random - provider for generating random values
      Returns:
      generated value