How can I use java streams to filter an object by the same porperty?
The HashSet tasks
contains:
task=1, name=hello
task=2, name=hello
(I dont want to use equals/hashcode on "name")
Now I want to filter the tasks
producing a new HashSet
with unique name
-property.
All objects having the same name should be treated as equal:
tasks.stream.filter(???);
I can solve that by creating a new list and with 2 for-loops by indexing next element and looking for the name
if it was already put into the list. However, maybe there is an one liner for such problems? Maybe with stream.filter()
?