Interface StreamableArbitrary<T,U>

All Superinterfaces:
Arbitrary<U>, SizableArbitrary<U>
All Known Subinterfaces:
ArrayArbitrary<T,A>, IteratorArbitrary<T>, ListArbitrary<T>, SetArbitrary<T>, StreamArbitrary<T>

@API(status=MAINTAINED, since="1.2.1") public interface StreamableArbitrary<T,U> extends SizableArbitrary<U>
Fluent interface to add functionality to arbitraries whose generation artefacts can be streamed, e.g. List, Set, Stream and Arrays
  • Method Details

    • reduce

      <R> Arbitrary<R> reduce(R initial, BiFunction<R,T,R> accumulator)
      Given an initial argument use accumulator to produce the final result.
      Type Parameters:
      R - The result type
      Parameters:
      initial - The initial argument. Also the result if streamable is empty
      accumulator - The function used to reduce a streamable into a result one by one
      Returns:
      The result of accumulating all elements in streamable
    • ofSize

      default StreamableArbitrary<T,U> ofSize(int size)
      Fix the size to size.
      Specified by:
      ofSize in interface SizableArbitrary<T>
    • ofMinSize

      StreamableArbitrary<T,U> ofMinSize(int minSize)
      Set lower size boundary minSize (included).
      Specified by:
      ofMinSize in interface SizableArbitrary<T>
    • ofMaxSize

      StreamableArbitrary<T,U> ofMaxSize(int maxSize)
      Set upper size boundary maxSize (included).
      Specified by:
      ofMaxSize in interface SizableArbitrary<T>
    • withSizeDistribution

      @API(status=EXPERIMENTAL, since="1.5.3") StreamableArbitrary<T,U> withSizeDistribution(RandomDistribution distribution)
      Set distribution distribution of size of generated arbitrary
      Specified by:
      withSizeDistribution in interface SizableArbitrary<T>
    • uniqueElements

      @API(status=MAINTAINED, since="1.7.3") StreamableArbitrary<T,U> uniqueElements()
      Add the constraint that elements of the generated streamable must be unique, i.e. no two elements must return true when being compared using Object.equals(Object).

      The constraint can be combined with other uniqueElements(Function) constraints.

      Returns:
      new arbitrary instance
    • uniqueElements

      @API(status=MAINTAINED, since="1.7.3") StreamableArbitrary<T,U> uniqueElements(Function<T,Object> by)
      Add the constraint that elements of the generated streamable must be unique relating to an element's "feature" being extracted using the by function. The extracted features are being compared using Object.equals(Object).

      The constraint can be combined with other uniqueElements(Function) constraints.

      Returns:
      new arbitrary instance