xxxxxxxxxx
Set<Object> uniques = new TreeSet<>(
Comparator.comparing(Object::att1).thenComparing(Object::att2));
xxxxxxxxxx
import static java.util.Comparator.comparingInt;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toCollection;
List<Employee> unique = employee.stream()
.collect(collectingAndThen(toCollection(() -> new TreeSet<>(comparingInt(Employee::getId))),
ArrayList::new));
xxxxxxxxxx
List<Obj> list = ; // list contains multiple objects
Collection<Obj> nonDuplicateCollection = list.stream()
.collect(Collectors.toMap(Obj::generateUniqueKey, Function.identity(), (a, b) -> a))
.values();