Class PeriodGenerator

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

public class PeriodGenerator extends Generator<Period>
Produces values of type Period.
  • Field Details

  • Constructor Details

    • PeriodGenerator

      public PeriodGenerator()
  • 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.

      If an endpoint of the range is not specified, the generator will use Periods with values of either Period(Year#MIN_VALUE, -12, -31) or Period(Year#MAX_VALUE, 12, 31) as appropriate.

      InRange.format() is ignored. Periods are always parsed using formats based on the ISO-8601 period formats PnYnMnD and PnW.

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

      public Period 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
    • toBigInteger

      private BigInteger toBigInteger(Period period)
    • fromBigInteger

      private Period fromBigInteger(BigInteger period)