Class CollectionTestOps

java.lang.Object
org.soliscode.test.util.CollectionTestOps

public final class CollectionTestOps extends Object

This class consists exclusively of static methods that operate on or return collections.

The methods of this class all throw a NullPointerException if the iterables or class objects provided to them are null.

Since:
1.0.0
Author:
evanbergstrom
  • Method Details

    • removeAllByIdentity

      public static <E> Collection<E> removeAllByIdentity(Collection<E> c, Collection<?> e)
      Removed all the elements in a collection that have the same identity as the elements in another collection.
      Type Parameters:
      E - the element type.
      Parameters:
      c - the collection to remove the elements from
      e - the collection of elements to remove.
      Returns:
      the collection without the removed elements.
    • preventNulls

      public static <E> Collection<E> preventNulls(Collection<E> c)
      Creates a collection backed by the provided collection that does not accept null values as elements.
      Type Parameters:
      E - The element type of the collection
      Parameters:
      c - The collection.
      Returns:
      A collection that does not accept null values.
    • preventNulls

      public static <E> List<E> preventNulls(List<E> c)
      Creates a collection backed by the provided collection that does not accept null values as elements.
      Type Parameters:
      E - The element type of the collection
      Parameters:
      c - The collection.
      Returns:
      A collection that does not accept null values.
    • listOf

      public static <E> List<E> listOf(E e1, E e2, E e3)
    • getGenericParameter

      public static Class<?> getGenericParameter(@NotNull @NotNull Object o, int parameter)
      Gets the class of the a generic parameter form an instance of the generic class.
      Parameters:
      o - an instance of a generic class.
      parameter - the index of the generic parameter to get the class for.
      Returns:
      the class object fo the generic parameter.
    • toCSVString

      public static String toCSVString(Collection<?> collection)