Код: Выделить всё
public List getFilteredList(List l1) {
return l1
.stream()
.filter(distinctByKey(XYZ::getName))
.filter(distinctByKey(XYZ::getPrice))
.collect(Collectors.toList());
}
private static Predicate distinctByKey(Function
Подробнее здесь: [url]https://stackoverflow.com/questions/72571561/why-is-putifabsent-compared-with-null-in-this-implementation-of-distinctbykey[/url]