Package software.amazon.smithy.utils
Class ListUtils
java.lang.Object
software.amazon.smithy.utils.ListUtils
Immutable List utilities to polyfill Java 9+ features.
- 
Method SummaryModifier and TypeMethodDescriptionstatic <T> List<T>copyOf(Collection<? extends T> values) Creates an immutable copy of the given list.static <T> List<T>of()Returns an unmodifiable list containing zero entries.static <T> List<T>of(T value) Returns an unmodifiable list containing a single entry.static <T> List<T>of(T... values) Returns an unmodifiable list containing any number of entries.static <T> List<T>of(T value1, T value2) Returns an unmodifiable list containing two entries.Creates a collector that collects into an unmodifiable list.
- 
Method Details- 
copyOfCreates an immutable copy of the given list.- Type Parameters:
- T- the List's value type.
- Parameters:
- values- The collection to make an immutable list of.
- Returns:
- An immutable List copy.
 
- 
ofReturns an unmodifiable list containing zero entries.- Type Parameters:
- T- the List's value type.
- Returns:
- an empty List.
 
- 
ofReturns an unmodifiable list containing a single entry.- Type Parameters:
- T- the List's value type.
- Parameters:
- value- the List's value.
- Returns:
- a List containing the specified value.
- Throws:
- NullPointerException- if the value is- null.
 
- 
ofReturns an unmodifiable list containing two entries.- Type Parameters:
- T- the List's value type.
- Parameters:
- value1- The first value.
- value2- The second value.
- Returns:
- a List containing the specified values.
 
- 
ofReturns an unmodifiable list containing any number of entries.- Type Parameters:
- T- the List's value type.
- Parameters:
- values- the List's values.
- Returns:
- a List containing the specified values.
- Throws:
- NullPointerException- if any value is- null.
 
- 
toUnmodifiableListCreates a collector that collects into an unmodifiable list.This is a polyfill equivalent of Java 10's Collectors#toUnmodifiableList.- Type Parameters:
- T- Type of value to expect.
- Returns:
- a Collector that accumulates the entries into an unmodifiable List.
 
 
-