공부
[Java] distinct by property
승가비
2020. 10. 28. 01:08
728x90
public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
Set<Object> seen = ConcurrentHashMap.newKeySet();
return t -> seen.add(keyExtractor.apply(t));
}
https://stackoverflow.com/questions/23699371/java-8-distinct-by-property
Java 8 Distinct by property
In Java 8 how can I filter a collection using the Stream API by checking the distinctness of a property of each object? For example I have a list of Person object and I want to remove people with ...
stackoverflow.com
728x90