Interface ListArbitrary<T extends @Nullable Object>

All Superinterfaces:
Arbitrary<List<T>>, SizableArbitrary<List<T>>, StreamableArbitrary<T,List<T>>

@API(status=MAINTAINED, since="1.3.2") public interface ListArbitrary<T extends @Nullable Object> extends Arbitrary<List<T>>, StreamableArbitrary<T,List<T>>
Fluent interface to add functionality to arbitraries that generate instances of type List
  • Method Details

    • ofSize

      default ListArbitrary<T> ofSize(int size)
      Fix the size to size.
      Specified by:
      ofSize in interface SizableArbitrary<T extends @Nullable Object>
      Specified by:
      ofSize in interface StreamableArbitrary<T extends @Nullable Object,List<T extends @Nullable Object>>
      Parameters:
      size - The size of the generated list
      Returns:
      new arbitrary instance
    • ofMinSize

      ListArbitrary<T> ofMinSize(int minSize)
      Set lower size boundary minSize (included).
      Specified by:
      ofMinSize in interface SizableArbitrary<T extends @Nullable Object>
      Specified by:
      ofMinSize in interface StreamableArbitrary<T extends @Nullable Object,List<T extends @Nullable Object>>
      Parameters:
      minSize - The minimum size of the generated list
      Returns:
      new arbitrary instance
    • ofMaxSize

      ListArbitrary<T> ofMaxSize(int maxSize)
      Set upper size boundary maxSize (included).
      Specified by:
      ofMaxSize in interface SizableArbitrary<T extends @Nullable Object>
      Specified by:
      ofMaxSize in interface StreamableArbitrary<T extends @Nullable Object,List<T extends @Nullable Object>>
      Parameters:
      maxSize - The maximum size of the generated list
      Returns:
      new arbitrary instance
    • withSizeDistribution

      @API(status=EXPERIMENTAL, since="1.5.3") ListArbitrary<T> withSizeDistribution(RandomDistribution uniform)
      Set random distribution distribution of size of generated list. The distribution's center is the minimum size of the generated list.
      Specified by:
      withSizeDistribution in interface SizableArbitrary<T extends @Nullable Object>
      Specified by:
      withSizeDistribution in interface StreamableArbitrary<T extends @Nullable Object,List<T extends @Nullable Object>>
    • mapEach

      @API(status=MAINTAINED, since="1.4.0") <U extends @Nullable Object> Arbitrary<List<U>> mapEach(BiFunction<? super List<? extends T>,? super T,? extends U> mapper)
      Map over each element of the generated list giving access to all elements of the list. The number and position of the mapped elements within the list will stay the same.
      Type Parameters:
      U - The target type of a list to generate
      Parameters:
      mapper - Mapper function to element type U
      Returns:
      arbitrary of a list of Us
    • flatMapEach

      @API(status=MAINTAINED, since="1.4.0") <U> Arbitrary<List<U>> flatMapEach(BiFunction<? super List<? extends T>,? super T,? extends Arbitrary<U>> flatMapper)
      Flat-map over each element of the generated list giving access to all elements of the list. The number and position of the mapped elements within the list will stay the same.
      Type Parameters:
      U - The target type of a list to generate
      Parameters:
      flatMapper - Mapper function to arbitrary of element type U
      Returns:
      arbitrary of a list of Us
    • uniqueElements

      @API(status=MAINTAINED, since="1.4.0") ListArbitrary<T> uniqueElements()
      Add the constraint that elements of the generated list 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.

      Specified by:
      uniqueElements in interface StreamableArbitrary<T extends @Nullable Object,List<T extends @Nullable Object>>
      Returns:
      new arbitrary instance
    • uniqueElements

      @API(status=MAINTAINED, since="1.4.0") ListArbitrary<T> uniqueElements(Function<? super T,?> by)
      Add the constraint that elements of the generated list 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.

      Specified by:
      uniqueElements in interface StreamableArbitrary<T extends @Nullable Object,List<T extends @Nullable Object>>
      Returns:
      new arbitrary instance