com.olapdb.obase.utils.MapUtil Maven / Gradle / Ivy
The newest version!
package com.olapdb.obase.utils;
import java.util.Map;
public class MapUtil {
public static Map addToMap1(
Map a,
Map b){
b.entrySet().stream().forEach(e->{
a.put(e.getKey(), a.getOrDefault(e.getKey(),0) + e.getValue());
});
return a;
}
public static Map> addToMap2(
Map> a,
Map> b){
b.entrySet().stream().forEach(e->{
String cateory = e.getKey();
if(!a.containsKey(cateory)){
a.put(cateory, e.getValue());
}else{
Map target = a.get(cateory);
addToMap1(target, e.getValue());
}
});
return a;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy