Setup and question
I have a stream over a simple Java data class like:
class Candidate{
    private Long id;
    private String fullName;
    private String job;
    private String adress;
}
I would like to filter my stream by two properties:
- remove all duplicates by job
- but keep everyone with adress"Italy"regardless ofjob
Example
Consider an example data set like
| ID | fullName | JOB | adress | 
|---|---|---|---|
| 1 | Peter Bright | IT Engineer | Italy | 
| 2 | Patrick Manon | Electronics engineer | Spain | 
| 3 | Bob Jina | IT Engineer | Suisse | 
| 4 | Alexander Layo | Security Engineer | UK | 
or in Java:
Candidate c1 = new Candidate(1,"Peter Bright","IT Engineer","Italy");
Candidate c2 = new Candidate(2,"Patrick Manon","Electronics engineer","Spain");
Candidate c3 = new Candidate(3,"Bob Jina","IT Engineer","Suisse");
Candidate c4 = new Candidate(4,"Alexander Layo","Security Engineer","UK");
Stream<Candidate> candidates = Stream.of(c1, c2, c3, c4);
I would like to filter the stream in a way that the outcome is:
| ID | fullName | JOB | ADSRESS | 
|---|---|---|---|
| 1 | Peter Bright | IT Engineer | Italy | 
| 2 | Patrick Manon | Electronics engineer | Spain | 
| 4 | Alexander Layo | Security Engineer | UK | 
Note that Bob Jina got removed since IT Engineer was already there.
In the case of there is duplicates candidates all from Italy we need to keep all of them
 
     
     
    