Lets consider I have two lists
List1:
[{
“problem”: “prb1",
“status”: “ACTIVE”,
“createTs”: “somedate-1"
}]
List 2:
[{
“problem”: “prb1",
“status”: “ACTIVE”,
“date”: “somedate-1"
},
{
“problem”: “prb1",
“status”: “ACTIVE”,
“date”: “somedate-2"
}]
I want to see if there is an ACTIVE problem in the list2 that doesn't exist as ACTIVE in the list1.
I tried below which is not covering duplicate entry(above scenario)
list2.removeAll(list1);
activeprob =
list2
.stream()
.filter(Objects::nonNull)
.filter(list -> list.getStatus().equals("ACTIVE"))
.collect(Collectors.toList());
In other way I want to eliminate the duplicate entry in list2 comparing with list1 based on status and date. having same problem is not a concern but should be unique in terms of date.
Please share your insights