以下があります。
public List<Balance> mapToBalancesWithSumAmounts(List<MonthlyBalancedBooking> entries) {
return entries
.stream()
.collect(
groupingBy(
MonthlyBalancedBooking::getValidFor,
summingDouble(MonthlyBalancedBooking::getAmount)
)
)
.entrySet()
.stream()
.map(localDateDoubleEntry -> new Balance(localDateDoubleEntry.getValue(), localDateDoubleEntry.getKey()))
.collect(toList());
}
コード内の 2 番目の stream() パスを回避する可能性はありますか?この場合、groupingBy() の結果はリストになるはずです。map() 関数を collect または groupingBy に渡す可能性が必要ですが、それは Java 8 で可能ですか?