Class ListOf<T>

java.lang.Object
org.opentestfactory.utils.ListOf<T>
Type Parameters:
T - the element type.

public class ListOf<T> extends Object
List wrapper to add filtering and extraction functions to lists.
Author:
jthebault
  • Constructor Details

  • Method Details

    • attributeMatchValue

      public final <A> ListOf<T> attributeMatchValue(Function<T,A> getter, A matchingValue)
      Get all list elements with the given (non null) value for an attribute retrieved through the provided getter.
      Type Parameters:
      A - type of the target attribute.
      Parameters:
      getter - the member function of list element type T that returns the target attribute.
      matchingValue - the target attribute value. null values trigger NullPointerException. To select for undefined attributes, use attributeMatchUndefined(Function)
      Returns:
      a ListOf instance containing all elements where the target attribute matches the required value.
    • attributeMatchUndefined

      public final <A> ListOf<T> attributeMatchUndefined(Function<T,A> getter)
      Get all list elements where the attribute is null.
      Type Parameters:
      A - type of the target attribute.
      Parameters:
      getter - accessor for the target attribute.
      Returns:
      a ListOf instance containing all elements where the target attribute value is undefined (null value)
    • attributeMatchAny

      public <A> ListOf<T> attributeMatchAny(Function<T,A> getter, Collection<A> matchingValues)
      Get all list elements which value for the target attribute is in the given list.
      Type Parameters:
      A - type of the target attribute.
      Parameters:
      getter - accessor for the target attribute.
      matchingValues - a collection containing all desired attribute values. If the collection allows for null elements, they may be used (and select list elements for which the target attribute is null).

      NB : switch this class to the trace log level of you suspect that null values get unduly excluded by a non-null tolerant matchingValues collection in your test case.

      Returns:
      a ListOf instance containing all elements where the target attribute matches one of the elements in matchingValues.
    • pluck

      public <A> List<A> pluck(Function<T,A> getter)
    • toList

      public List<T> toList()
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object