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