Here you can find the source of sumCurrencyMap(Map
public static Map sumCurrencyMap(Map<String, Map<String, BigDecimal>> destMap, Map<String, Map<String, BigDecimal>> mapToSum)
//package com.java2s; /**/* www. j av a2s . c o m*/ * License: https://github.com/votingsystem/votingsystem/wiki/Licencia */ import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; public class Main { public static Map sumCurrencyMap(Map<String, Map<String, BigDecimal>> destMap, Map<String, Map<String, BigDecimal>> mapToSum) { Map<String, BigDecimal> tagMap = null; for (String currency : mapToSum.keySet()) { if ((tagMap = destMap.get(currency)) != null) { for (String tag : mapToSum.get(currency).keySet()) { if (tagMap.containsKey(tag)) { BigDecimal newAmount = tagMap.get(tag).add(mapToSum.get(currency).get(tag)); tagMap.put(tag, newAmount); } else { tagMap.put(tag, mapToSum.get(currency).get(tag)); } } } else { destMap.put(currency, new HashMap<>(mapToSum.get(currency))); } } return destMap; } }