Package net.jqwik.api

Interface Shrinkable<T>

  • All Superinterfaces:

    public interface Shrinkable<T>
    extends java.lang.Comparable<Shrinkable<T>>
    • Method Detail

      • unshrinkable

        static <T> Shrinkable<T> unshrinkable​(T value)
      • supplyUnshrinkable

        static <T> Shrinkable<T> supplyUnshrinkable​(java.util.function.Supplier<T> supplier,
                                                    boolean cacheImmutables)
      • value

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

             since="1.3.3")<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!

        a finite stream of shrinking options
      • grow

        default java.util.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.
        before - The other shrinkable before shrinking
        after - The other shrinkable after shrinking
        this shrinkable grown by the difference of before and after
      • grow

        default<Shrinkable<T>> grow()
        Grow a shrinkable to allow broader searching in flat mapped shrinkables
        a finite stream of grown values
      • asGeneric

        default Shrinkable<java.lang.Object> asGeneric()
        Sometimes simplifies test writing
        generic version of a shrinkable
      • map

        default <U> Shrinkable<U> map​(java.util.function.Function<T,​U> mapper)
      • filter

        default Shrinkable<T> filter​(java.util.function.Predicate<T> filter)
      • flatMap

        default <U> Shrinkable<U> flatMap​(java.util.function.Function<T,​Arbitrary<U>> flatMapper,
                                          int tries,
                                          long randomSeed)
      • compareTo

        default int compareTo​(Shrinkable<T> other)
        Specified by:
        compareTo in interface java.lang.Comparable<T>
      • makeUnshrinkable

        default Shrinkable<T> makeUnshrinkable()