public final class SetUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.util.Set<java.lang.String> |
caseInsensitiveCopyOf(java.util.Collection<? extends java.lang.String> values) |
static <T> java.util.Set<T> |
copyOf(java.util.Collection<? extends T> values)
Creates an immutable copy of the given set.
|
static <T> java.util.Set<T> |
of()
Returns an unmodifiable set containing zero entries.
|
static <T> java.util.Set<T> |
of(T... values)
Returns an unmodifiable set containing any number of entries.
|
static <T> java.util.Set<T> |
of(T value)
Returns an unmodifiable set containing a single entry.
|
static <T> java.util.Set<T> |
orderedCopyOf(java.util.Collection<? extends T> values)
Creates an ordered immutable copy of the given set.
|
static <T> java.util.stream.Collector<T,?,java.util.Set<T>> |
toUnmodifiableSet()
Creates a collector that collects into an unmodifiable set.
|
public static <T> java.util.Set<T> copyOf(java.util.Collection<? extends T> values)
T
- the Set's value type.values
- The collection to make an immutable set of.public static <T> java.util.Set<T> orderedCopyOf(java.util.Collection<? extends T> values)
T
- the Set's value type.values
- The collection to make an immutable set of.public static java.util.Set<java.lang.String> caseInsensitiveCopyOf(java.util.Collection<? extends java.lang.String> values)
public static <T> java.util.Set<T> of()
T
- the Set's value type.public static <T> java.util.Set<T> of(T value)
T
- the Set's value type.value
- the Set's value.java.lang.NullPointerException
- if the value is null
.@SafeVarargs public static <T> java.util.Set<T> of(T... values)
T
- the Set's value type.values
- the Set's values.java.lang.IllegalArgumentException
- if any of the values is a duplicate.java.lang.NullPointerException
- if any value is null
.public static <T> java.util.stream.Collector<T,?,java.util.Set<T>> toUnmodifiableSet()
This is a polyfill equivalent of Java 10's
Collectors#toUnmodifiableSet
.
T
- the Set's value type.