Package net.jqwik.api

Interface Shrinkable<T extends @Nullable Object>

All Superinterfaces:
Comparable<Shrinkable<T>>

@API(status=STABLE, since="1.0") public interface Shrinkable<T extends @Nullable Object> extends Comparable<Shrinkable<T>>
  • Method Details

    • unshrinkable

      static <T extends @Nullable Object> Shrinkable<T> unshrinkable(T value)
    • unshrinkable

      static <T extends @Nullable Object> Shrinkable<T> unshrinkable(T value, ShrinkingDistance distance)
    • supplyUnshrinkable

      @API(status=INTERNAL) static <T extends @Nullable Object> Shrinkable<T> supplyUnshrinkable(Supplier<? extends T> supplier)
    • value

      T value()
      Create value freshly, so that in case of mutable objects shrinking (and reporting) can rely on untouched values.
      Returns:
      An un-changed instance of the value represented by this shrinkable
    • shrink

      @API(status=INTERNAL, since="1.3.3") Stream<Shrinkable<T>> shrink()
      Create a new and finite stream of smaller or same size shrinkables; size is measured by distance().

      Same size shrinkables are allowed but they have to iterate towards a single value to prevent endless shrinking. This also means that a shrinkable must never be in its own shrink stream!

      Returns:
      a finite stream of shrinking options
    • grow

      @API(status=INTERNAL, since="1.3.3") default Optional<Shrinkable<T>> grow(Shrinkable<?> before, Shrinkable<?> after)
      To be able to "move" values towards the end of collections while keeping some constraint constant it's necessary to grow a shrinkable by what another has been shrunk. One example is keeping a sum of values and still shrinking to the same resulting list.
      Parameters:
      before - The other shrinkable before shrinking
      after - The other shrinkable after shrinking
      Returns:
      this shrinkable grown by the difference of before and after
    • grow

      @API(status=INTERNAL, since="1.3.3") default Stream<Shrinkable<T>> grow()
      Grow a shrinkable to allow broader searching in flat mapped shrinkables
      Returns:
      a finite stream of grown values
    • distance

      ShrinkingDistance distance()
    • asGeneric

      @API(status=INTERNAL, since="1.2.4") default Shrinkable<Object> asGeneric()
      Sometimes simplifies test writing
      Returns:
      generic version of a shrinkable
    • map

      default <U extends @Nullable Object> Shrinkable<U> map(Function<? super T,? extends U> mapper)
    • filter

      default Shrinkable<T> filter(Predicate<? super T> filter)
    • flatMap

      default <U extends @Nullable Object> Shrinkable<U> flatMap(Function<? super T,? extends Arbitrary<U>> flatMapper, int tries, long randomSeed)
    • compareTo

      @API(status=INTERNAL) default int compareTo(Shrinkable<T> other)
      Specified by:
      compareTo in interface Comparable<T extends @Nullable Object>
    • makeUnshrinkable

      @API(status=INTERNAL) default Shrinkable<T> makeUnshrinkable()