I have a list of:
public class Dto {
private Integer id;
private String text;
private BigDecimal price;
}
I tried:
Map<String, Map<Integer, List<Dto>>> map =
list.stream()
.collect(
Collectors.groupingBy(
Dto::getText,
Collectors.groupingBy(Dto::getId)));
but this did not give a sum of the BigDecimal field
Also I would like to have the return structure like:
List<SumDto>
public class SumDto {
private Integer id;
private String text;
private BigDecimal sum;
}
How could I achieve this? Thank you very much