Given a java pojo containing the following fields
public class Pojo {
// for brevity I am excluding the property getters / setters etc.
private int V;
private BigDecimal Amount;
private String Operation;
private String Tag;
private String Code;
}
I have a list of pojos' that look like this. If I compare specifically Tag, Amount, Ver, and ignore Code, I would like to use a hash / stream / whatever to remove all the rows where there is exactly 1 "IU" and exactly 1 "DU" for the same Tag, Amount, and Ver.
Is there a way to join or group streams to ensure that if there is exactly 1 insert update "IU" and exactly 1 delete update "DU" for the same values then both are removed?
Ver Amount Operation Tag Code
1 1 "IU" 6896450 5500
1 1 "DU" 6898103 5500
2 4 "IU" 6954561 5200
2 4 "DU" 6954561 5500
3 4 "IU" 7057717 5200
3 4 "DU" 7057717 5500
1 8 "IU" 7132952 5200
1 8 "DU" 7132952 5500
PojoKeyclass that references the Tag/Code/Op fields, then a couple ofMap<PojoKey, List<Pojo>>that you add them to, one for IU and one for DU. From there you have a well structured data model that you can work with, in this case comparing the two maps to find the union of them. you need to decide what to do with the case where there are multiple IU/DU per item.