I have different set of data like below and Now I want to group by ClientId+EffDate+Seccode
List<Transaction> list = new ArrayList<Transaction>();
for (int i=0; i <= 10 ; i++){
Transaction txn = new Transaction();
txn.setClientId(i);
txn.setEffDate("11/11/201"+i);
txn.setSecCode("PPD");
list.add(txn);
}
for (int i=5; i <= 10 ; i++){
Transaction txn = new Transaction();
txn.setClientId(i);
txn.setEffDate("11/11/201"+i);
txn.setSecCode("PPD");
list.add(txn);
}
I want to get data using below criteria
ClientId+EffDate+Seccode get list of transactions
I am trying to do using below incomplete code
Function<Transaction, List<Object>> keyExtractor = wr ->Arrays.<Object>asList(wr.getClientId(), wr.getEffDate(), wr.getSecCode());
Map<List<Object>, String> aggData = list.stream().collect(Collectors.groupingBy(keyExtractor).....
Any help is greatly appreciated
I have solved this issue using below code.