public <T, V> Map<String, Map<String, V>> convertMultistageMapByFunction( final Map<String, Map<String, List>> computeResultNameGroup, final Function<? super Map.Entry<String, List>, ? extends V> valueMapper) { return computeResultNameGroup.entrySet().stream() .collect(Collectors.toMap( Map.Entry::getKey, e -> e.getValue().entrySet().stream() .collect(Collectors.toMap( Map.Entry::getKey, valueMapper, (o, n) -> o )), (o, n) -> o )); }

Java 代码优化:使用 Stream API 转换多层 Map 结构

原文地址: https://www.cveoy.top/t/topic/qDDC 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录