I got a list of custom objects in it. Every of these objects has a unique ID, but some of them got same names. I want to remove the duplicated objects by name (string value). Found this example in a similar question, but it compares the IDs, not the names.
List<Relation> unique = possibleRels.stream().collect(collectingAndThen(toCollection(() -> new TreeSet<>(comparingInt(Relation::getId))), t -> new ArrayList<>(t)));
Is there a method to delete duplicates from list, compared by a string value?