Javaの8ストリームを使用して副作用のない地図のリターン地図

julez:

どのように置けばいいの追加/ eServiceReportsMapByBatchFileキーでoldReportIdeServiceReportMap副作用なし?

Map<String, Map<String, Set<EServiceReport>>> eServiceReportMap = new HashMap<>();
reports.forEach(report -> {
    String oldReportId = report.getOldId();
        Map<String, Set<EServiceReport>> eServiceReportsMapByBatchFile = // processing of batch files
        ...
    eServiceReportMap.put(oldReportId, eServiceReportsMapByBatchFile);
});

return eServiceReportMap;

それは私がそれはこのようになりたい、次のとおりです。

return reports.stream()
    .map(report -> {
        String oldReportId = report.getOldId();
        Map<String, Set<EServiceReport>> eServiceReportsMapByBatchFile = // processing of batch files
        ...
        // I don't know how and what to return here
    }).collect(// I don't know what to do here);

ありがとうございました。

また:

あなたは主に楽しみにしていますにCollectors.toMapどのように使用することができます。

return reports.stream()
        .collect(Collectors.toMap(report -> report.getOldId(),
                        report -> {
                    // batch processing for eServiceReportsMapByBatchFile
                            return eServiceReportsMapByBatchFile;
                }));

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=183928&siteId=1