Class CollectionTestOps
java.lang.Object
org.soliscode.test.util.CollectionTestOps
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 Summary
Modifier and TypeMethodDescriptionstatic Class
<?> getGenericParameter
(@NotNull Object o, int parameter) Gets the class of the a generic parameter form an instance of the generic class.static <E> List
<E> listOf
(E e1, E e2, E e3) static <E> Collection
<E> preventNulls
(Collection<E> c) Creates a collection backed by the provided collection that does not accept null values as elements.static <E> List
<E> preventNulls
(List<E> c) Creates a collection backed by the provided collection that does not accept null values as elements.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.static String
toCSVString
(Collection<?> collection)
-
Method Details
-
removeAllByIdentity
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 frome
- the collection of elements to remove.- Returns:
- the collection without the removed elements.
-
preventNulls
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
-
listOf
-
getGenericParameter
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
-