| Modifier and Type | Method and Description |
|---|---|
static <T> Set<T> |
fromArray(T[] array)
Deprecated.
Use
set(Object...) instead. |
static Set<String> |
fromCSV(String csv)
Creates a set containing the elements of a comma separated string, with
the caveat that the processing is done by
StringTokenizer with the
delimiter ",". |
static <T> Set<T> |
fromIterable(Iterable<T> iterable)
Creates a set containing the elements of the given iterable.
|
static <T> Set<T> |
fromIterator(Iterator<T> iterator)
Creates a set containing the elements of the given iterator.
|
static <T> Set<T> |
fromList(List<T> list)
Create a set containing the elements of the given list.
|
static <T> Set<T> |
immutableSetOfType(Set<?> set,
Class<T> type)
Checks that all elements of the set are of the specified type, and returns
an unmodifiable copy of the set, with null elements disallowed.
|
static <T> Set<T> |
immutableSetOfTypeOrNull(Set<?> set,
Class<T> type)
Checks that all elements of the set are of the specified type, and returns
an unmodifiable copy of the set, with null elements allowed.
|
static <T> Set<T> |
set(T... elements)
Creates a modifiable set from any number of arguments.
|
static <T> Set<T> |
theSet(Collection<T> coll)
Create a set containing the elements of the given collection.
|
public static <T> Set<T> set(T... elements)
Creates a modifiable set from any number of arguments.
T - The type of element contained in the set.elements - A succession of elements (possibly zero).Set of those elements (an empty set if no
elements).CollectionUtil2.collection(Supplier, Object...)public static <T> Set<T> immutableSetOfType(Set<?> set, Class<T> type)
Checks that all elements of the set are of the specified type, and returns an unmodifiable copy of the set, with null elements disallowed.
T - The type of element contained in the set.set - The input set.type - The class with which all items of the set must be
assignment-compatible.NullPointerException - if the set is null or if any element is null.ClassCastException - if an item is not of the proper type.immutableSetOfType(Set, Class, boolean)public static <T> Set<T> immutableSetOfTypeOrNull(Set<?> set, Class<T> type)
Checks that all elements of the set are of the specified type, and returns an unmodifiable copy of the set, with null elements allowed.
T - The type of element contained in the set.set - The input set.type - The class with which all items of the set must be
assignment-compatible.NullPointerException - if the set is nullClassCastException - if an item is not of the proper type.immutableSetOfType(Set, Class, boolean)@Deprecated public static <T> Set<T> fromArray(T[] array)
set(Object...) instead.
Now that set(Object...) is generic, this method does
exactly the same thing and simply calls it.
T - The type of element contained in the set.array - An array of objects.Set made of the objects in the array.set(Object...)public static <T> Set<T> theSet(Collection<T> coll)
Create a set containing the elements of the given collection.
T - The type of element contained in the set.coll - A collection.HashSet.HashSet(Collection)public static <T> Set<T> fromList(List<T> list)
Create a set containing the elements of the given list.
T - The type of element contained in the set.list - A list.theSet(Collection)public static <T> Set<T> fromIterator(Iterator<T> iterator)
Creates a set containing the elements of the given iterator.
T - The type of element contained in the set.iterator - An iterator.CollectionUtil2.fromIterator(Supplier, Iterator)public static <T> Set<T> fromIterable(Iterable<T> iterable)
Creates a set containing the elements of the given iterable.
T - The type of element contained in the set.iterable - An iterable.CollectionUtil2.fromIterable(Supplier, Iterable)public static Set<String> fromCSV(String csv)
Creates a set containing the elements of a comma separated string, with
the caveat that the processing is done by StringTokenizer with the
delimiter ",".
StringTokenizer simplistically looks for separators without a
quoting mechanism to return tokens containing the delimiter, nor does it
trim whitespace between tokens and delimiters. It also does not return
empty tokens, so calling this method with ",,," will return an
empty set, not a set of four empty strings.
csv - A simplistic CSV string.CollectionUtil2.fromCsvStringTokenizer(Supplier, String)Copyright © 2000–2018 LOCKSS Program. All rights reserved.