The distinct() stream operation compares the stream’s elements directly to each other using Object.equals(), but there’s no obvious way to have it compute uniqueness based on some value derived from each stream element.
Here’s a snippet of code do this. This is used in a filter() operation, and it takes a key extractor function to […]