I have a list of Person objects and I want to remove similar (i.e. having the same `objects from it.
public class Person {
private String name;
private int age;
private boolean isSelfEmployed;
// getters, constructor, etc.
}
Sample data:
List<Person> personList = new ArrayList<>();
personList.add(new Person("John", 26, true)); // Include
personList.add(new Person("Erica", 29, false)); // Include
personList.add(new Person("John", 26, false)); // Exclude
For Person objects having the same name and age I want to remove only those objects where isSelfEmployed property is false (i.e. the final list should contain only the first and the second objects).
I'm wonder is it possible to achieve using streams?