Modifier and Type | Method and Description |
---|---|
static <T> Collector<T,?,T> |
single()
Collect a single element.
|
static <T> Collector<T,?,Optional<T>> |
singleOrEmpty()
Eventually collect a single element.
|
static <T extends Map.Entry<K,U>,K,U> |
toMap()
Collect map entries into a
HashMap . |
static <T,K,U,M extends Map<K,U>> |
toMap(Function<? super T,? extends K> keyMapper,
Function<? super T,? extends U> valueMapper,
Supplier<M> mapSupplier)
Collect map entries into a map.
|
static <T extends Map.Entry<K,U>,K,U,M extends Map<K,U>> |
toMap(Supplier<M> mapSupplier)
Collect map entries into a map.
|
static <T extends Map.Entry<K,U>,K,U> |
toMapWithNullValues()
Collect map entries into a
HashMap , allowing null values. |
static <T,K,U,M extends Map<K,U>> |
toMapWithNullValues(Function<? super T,? extends K> keyMapper,
Function<? super T,? extends U> valueMapper,
Supplier<M> mapSupplier)
Collect map entries into a map, allowing null values.
|
static <T extends Map.Entry<K,U>,K,U,M extends Map<K,U>> |
toMapWithNullValues(Supplier<M> mapSupplier)
Collect map entries into a map, allowing null values.
|
public static <T> Collector<T,?,T> single() throws IllegalArgumentException
IllegalArgumentException
if no or more than one element.T
- Element typeIllegalArgumentException
public static <T> Collector<T,?,Optional<T>> singleOrEmpty()
IllegalArgumentException
if more than one element.T
- Element typepublic static <T extends Map.Entry<K,U>,K,U> Collector<T,?,Map<K,U>> toMap()
HashMap
.
The Collector throws NullPointerException
if one entry has a null value.
The Collector throws IllegalStateException
if duplicate keys are found.T
- the Map entry typeK
- the collected map key typeU
- the collected map value typeCollector
which collects elements into a Map
public static <T extends Map.Entry<K,U>,K,U,M extends Map<K,U>> Collector<T,?,M> toMap(Supplier<M> mapSupplier)
NullPointerException
if one entry has a null value.
The Collector throws IllegalStateException
if duplicate keys are found.M
- the type of the resulting Map
T
- the Map entry typeK
- the collected map key typeU
- the collected map value typemapSupplier
- a function which returns a new, empty Map
into
which the results will be insertedpublic static <T,K,U,M extends Map<K,U>> Collector<T,?,M> toMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper, Supplier<M> mapSupplier)
NullPointerException
if one entry has a null value.
The Collector throws IllegalStateException
if duplicate keys are found.M
- the type of the resulting Map
T
- the Map entry typeK
- the collected map key typeU
- the collected map value typekeyMapper
- a mapping function to produce keysvalueMapper
- a mapping function to produce valuesmapSupplier
- a function which returns a new, empty Map
into
which the results will be insertedpublic static <T extends Map.Entry<K,U>,K,U> Collector<T,?,Map<K,U>> toMapWithNullValues()
HashMap
, allowing null values.
The Collector throws IllegalStateException
if duplicate keys are found.
See https://bugs.openjdk.java.net/browse/JDK-8148463T
- the Map entry typeK
- the collected map key typeU
- the collected map value typepublic static <T extends Map.Entry<K,U>,K,U,M extends Map<K,U>> Collector<T,?,M> toMapWithNullValues(Supplier<M> mapSupplier)
IllegalStateException
if duplicate keys are found.
See https://bugs.openjdk.java.net/browse/JDK-8148463M
- the type of the resulting Map
T
- the Map entry typeK
- the collected map key typeU
- the collected map value typemapSupplier
- a function which returns a new, empty Map
into
which the results will be insertedpublic static <T,K,U,M extends Map<K,U>> Collector<T,?,M> toMapWithNullValues(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper, Supplier<M> mapSupplier)
IllegalStateException
if duplicate keys are found.
See https://bugs.openjdk.java.net/browse/JDK-8148463M
- the type of the resulting Map
T
- the Map entry typeK
- the collected map key typeU
- the collected map value typekeyMapper
- a mapping function to produce keysvalueMapper
- a mapping function to produce valuesmapSupplier
- a function which returns a new, empty Map
into
which the results will be inserted