public class CollectionUtils extends Object
Constructor and Description |
---|
CollectionUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> Predicate<T> |
distinctByKey(Function<? super T,Object> keyExtractor)
Returns a stateful stream filter that, once applied to a stream, returns a stream consisting
of the distinct elements (according to the specified key).
|
public static <T> Predicate<T> distinctByKey(Function<? super T,Object> keyExtractor)
The implementation of Stream.distinct()
can be used to return a stream that has distinct
elements, based on the implementation of Object.equals(Object)
. That implementation does
not allow to filter a stream based on one property of each object. The implementation of provided
by this method does.
T
- Stream element type.keyExtractor
- A function to extract the desired key from the stream objects (cannot be null).Copyright © 2003–2019 Ignite Realtime. All rights reserved.