my problem is that I get java.lang.IllegalStateException: Duplicate key
every time I try to map a String
with List
. Is there a way to edit this implementation to somehow handle duplicate keys? Or should I do it in another way?
Map<String, List<Fee>> feeAccountMap = ContractList
.stream()
.filter(o -> !o.getStatus().equals(ContractStatus.CLOSED))
.collect(Collectors.toMap(o -> o.getFeeAccount(), o -> {
List<Fee> monthlyFees;
try {
monthlyFees = contractFeeService.getContractMonthlyFees(o);
} catch (Exception e) {
throw new RuntimeException(e);
}
return monthlyFees;
}
));