Class DurationGenerator

java.lang.Object
com.pholser.junit.quickcheck.generator.Generator<Duration>
com.pholser.junit.quickcheck.generator.java.time.DurationGenerator
All Implemented Interfaces:
Gen<Duration>, Shrink<Duration>

public class DurationGenerator extends Generator<Duration>
Produces values of type Duration.
  • Field Details

  • Constructor Details

    • DurationGenerator

      public DurationGenerator()
  • Method Details

    • configure

      public void configure(InRange range)

      Tells this generator to produce values within a specified minimum and/or maximum, inclusive, with uniform distribution, down to the nanosecond.

      If an endpoint of the range is not specified, the generator will use durations with second values of either Long.MIN_VALUE or Long.MAX_VALUE (with nanoseconds set to 999,999,999) as appropriate.

      InRange.format() is ignored. Durations are always parsed using formats based on the ISO-8601 duration format PnDTnHnMn.nS with days considered to be exactly 24 hours.

      Parameters:
      range - annotation that gives the range's constraints
      See Also:
    • generate

      public Duration generate(SourceOfRandomness random, GenerationStatus status)
      Description copied from interface: Gen
      Generates a value, possibly influenced by a source of randomness and metadata about the generation.
      Parameters:
      random - source of randomness to be used when generating the value
      status - an object that can be used to influence the generated value. For example, generating lists can use the size method to generate lists with a given number of elements.
      Returns:
      the generated value