Package com.globalmentor.collections
Class Sets
java.lang.Object
com.globalmentor.collections.Sets
Utilities to be used with sets.
- Author:
- Garret Wilson
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E> void
checkArgumentsEqual
(Set<E> set1, Set<E> set2) Checks that two sets are equal.static <E> Set<E>
immutableSetOf
(E... elements) Creates a read-only set containing the given elements.static <E> Set<E>
immutableSetOf
(Iterable<? extends E> iterable, E... elements) Creates a read-only set containing the elements of the provided iterable along with the given elements.static <E> Set<E>
immutableSetOf
(Collection<? extends E> collection, E... elements) Creates a read-only set containing the elements of the provided collection along with the given elements.
-
Constructor Details
-
Sets
public Sets()
-
-
Method Details
-
immutableSetOf
Creates a read-only set containing the given elements.- Type Parameters:
E
- The type of element contained in the set.- Parameters:
elements
- The elements to be contained in the set.- Returns:
- The immutable version of the set.
- Throws:
NullPointerException
- if the given array of elements isnull
.
-
immutableSetOf
Creates a read-only set containing the elements of the provided iterable along with the given elements.- Type Parameters:
E
- The type of element contained in the set.- Parameters:
iterable
- The existing iterable to augment.elements
- The elements to be contained in the set.- Returns:
- The immutable version of the set.
- Throws:
NullPointerException
- if the given iterable and/or array of elements isnull
.
-
immutableSetOf
Creates a read-only set containing the elements of the provided collection along with the given elements.- Type Parameters:
E
- The type of element contained in the set.- Parameters:
collection
- The existing collection to augment.elements
- The elements to be contained in the set.- Returns:
- The immutable version of the set.
- Throws:
NullPointerException
- if the given collection and/or array of elements isnull
.
-
checkArgumentsEqual
Checks that two sets are equal.This method performs logic equivalent to
Set.equals(Object)
, except that a descriptive exception is thrown on inequality. This is particularly useful for debugging.- Type Parameters:
E
- The type of the items contained in the set.- Parameters:
set1
- The first set to compare.set2
- The second test to compare.- Throws:
IllegalArgumentException
- if the sets are not equal.
-