public static <T, V> Map<String, Map<String, V>> convertMultistageMapByFunction( final Map<String, Map<String, T>> computeResultNameGroup, final Function<? super Map.Entry<String, T>, ? extends V> valueMapper) { if (computeResultNameGroup == null) { return Collections.emptyMap(); } Map<String, Map<String, V>> result = new LinkedHashMap<>(); for (Map.Entry<String, Map<String, T>> entry : computeResultNameGroup.entrySet()) { Map<String, V> innerMap = new LinkedHashMap<>(); for (Map.Entry<String, T> innerEntry : entry.getValue().entrySet()) { V value = valueMapper.apply(innerEntry); innerMap.put(innerEntry.getKey(), value); } result.put(entry.getKey(), innerMap); } return result; }

Java 代码优化:多层嵌套 Map 转化

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

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