Package software.amazon.smithy.utils
Class SetUtils
- java.lang.Object
- 
- software.amazon.smithy.utils.SetUtils
 
- 
 public final class SetUtils extends java.lang.ObjectImmutable Set utilities to polyfill Java 9+ features.
- 
- 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description 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 value)Returns an unmodifiable set containing a single entry.static <T> java.util.Set<T>of(T... values)Returns an unmodifiable set containing any number of entries.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.
 
- 
- 
- 
Method Detail- 
copyOfpublic static <T> java.util.Set<T> copyOf(java.util.Collection<? extends T> values) Creates an immutable copy of the given set.- Type Parameters:
- T- the Set's value type.
- Parameters:
- values- The collection to make an immutable set of.
- Returns:
- An immutable Set copy.
 
 - 
orderedCopyOfpublic static <T> java.util.Set<T> orderedCopyOf(java.util.Collection<? extends T> values) Creates an ordered immutable copy of the given set.- Type Parameters:
- T- the Set's value type.
- Parameters:
- values- The collection to make an immutable set of.
- Returns:
- An ordered immutable Set copy that maintains the order of the original.
 
 - 
ofpublic static <T> java.util.Set<T> of() Returns an unmodifiable set containing zero entries.- Type Parameters:
- T- the Set's value type.
- Returns:
- an empty Set.
 
 - 
ofpublic static <T> java.util.Set<T> of(T value) Returns an unmodifiable set containing a single entry.- Type Parameters:
- T- the Set's value type.
- Parameters:
- value- the Set's value.
- Returns:
- a Set containing the specified value.
- Throws:
- java.lang.NullPointerException- if the value is- null.
 
 - 
of@SafeVarargs public static <T> java.util.Set<T> of(T... values) Returns an unmodifiable set containing any number of entries.- Type Parameters:
- T- the Set's value type.
- Parameters:
- values- the Set's values.
- Returns:
- a Set containing the specified values.
- Throws:
- java.lang.IllegalArgumentException- if any of the values is a duplicate.
- java.lang.NullPointerException- if any value is- null.
 
 - 
toUnmodifiableSetpublic static <T> java.util.stream.Collector<T,?,java.util.Set<T>> toUnmodifiableSet() Creates a collector that collects into an unmodifiable set.This is a polyfill equivalent of Java 10's Collectors#toUnmodifiableSet.- Type Parameters:
- T- the Set's value type.
- Returns:
- a Collector that accumulates the entries into an unmodifiable Set.
 
 
- 
 
-