final MapString MapString MapString BigDecimal levelSubtotalDict return levelSubtotalDictentrySetstream collectCollectorstoMap MapEntrygetKey entry - entrygetV
This code takes a nested map called levelSubtotalDict and transforms it into a new map with a different structure.
The input map levelSubtotalDict has the following structure:
Map<String, Map<String, Map<String, BigDecimal>>>
The output map has the following structure:
Map<String, Map<String, List<ComputeResultExportDTO>>>
The transformation is done using Java streams and the collect method. Here's how it works:
- The
entrySet()method is called onlevelSubtotalDictto get a stream of key-value pairs from the outer map. - The
collectmethod is used to collect the stream into a new map. The key remains the same, but the value is transformed using the following steps: - The
entry.getValue()method is called to get the inner map for each outer key-value pair. - The
entrySet()method is called on the inner map to get a stream of key-value pairs from the inner map. - The
mapmethod is used to transform each inner key-value pair into a new key-value pair. The key is the same as the inner key, and the value is a list ofComputeResultExportDTOobjects. - Within the
mapmethod, thescoreMap.entrySet()method is called to get a stream of key-value pairs from the score map. - The
mapmethod is used to transform each score key-value pair into a newComputeResultExportDTOobject. The properties of this object are set based on the key-value pair and additional information from theempNameAndCodeobject. - The
collectmethod is used to collect the stream ofComputeResultExportDTOobjects into a list. - The resulting list of
ComputeResultExportDTOobjects is used as the value in the new key-value pair for the inner map. - The
collectmethod is used to collect the stream of inner key-value pairs into a new map. The key remains the same, and the value is the list ofComputeResultExportDTOobjects. - The resulting map is used as the value in the new key-value pair for the outer map.
- Finally, the outer map is collected and returned
原文地址: https://www.cveoy.top/t/topic/iYKs 著作权归作者所有。请勿转载和采集!