public interface Lambdas
Modifier and Type | Method and Description |
---|---|
static <T> Predicate<T> |
distinctByKey(Function<? super T,Object> keyExtractor)
Create a "distinct by property" predicate for filtering.
|
static <K,V> Collector<Map.Entry<K,V>,?,Map<K,V>> |
toMap()
Collect an Map.Entry stream into a Map.
|
static <T,K,V,M extends Map<K,V>> |
toMap(Function<? super T,? extends K> keyMapper,
Function<? super T,? extends V> valueMapper,
Supplier<M> mapSupplier)
This is the missing toMap() method on the Collectors class - specify
the key mapper, the value mapper, and the map supplier without having
to specify the value merge function.
|
static <K,V,M extends Map<K,V>> |
toMap(Supplier<M> mapSupplier)
Collect an Map.Entry stream into a Map using the specified map supplier.
|
static <T> Predicate<T> distinctByKey(Function<? super T,Object> keyExtractor)
persons.stream().filter(distinctByKey(p -> p.getName());
static <K,V> Collector<Map.Entry<K,V>,?,Map<K,V>> toMap()
K
- the type of key in the incoming entry streamV
- the type of value in the incoming entry streamstatic <K,V,M extends Map<K,V>> Collector<Map.Entry<K,V>,?,M> toMap(Supplier<M> mapSupplier)
K
- the type of key in the incoming entry streamV
- the type of value in the incoming entry streamM
- the type of the resulting Map
static <T,K,V,M extends Map<K,V>> Collector<T,?,M> toMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends V> valueMapper, Supplier<M> mapSupplier)
T
- the type of the input elementsK
- the output type of the key mapping functionV
- the output type of the value mapping functionM
- the type of the resulting Map
Copyright © 2015–2016 SYSTAP, LLC DBA Blazegraph. All rights reserved.