我有一段代码:
Map<String, BillingAccount> billingAccountsMap = new HashMap<>();
for (BillingAccount ba : billingAccounts) {
if (ba.getBillingAccountIdentifier() != null && ba.getBillingAccountIdentifier().getIdentifier() != null) {
billingAccountsMap.put(ba.getBillingAccountIdentifier().getIdentifier(), ba);
}
}
我只想用Java Stream API和collect(Collectors.toMap())
以功能性的方式重写它,但我对null
个 case 有点困惑.
我正在使用Java11.