本文整理了Java中java.util.LinkedHashMap.merge()
方法的一些代码示例,展示了LinkedHashMap.merge()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedHashMap.merge()
方法的具体详情如下:
包路径:java.util.LinkedHashMap
类名称:LinkedHashMap
方法名:merge
暂无
代码示例来源:origin: apache/metron
@Override
public Object apply(List<Object> list) {
LinkedHashMap<Object, Integer> ret = new LinkedHashMap<>();
if (list.size() >= 1) {
Object o = list.get(0);
if (o != null) {
if (!(o instanceof Iterable)) {
throw new IllegalArgumentException("Expected an Iterable, but " + o + " is of type " + o.getClass());
}
for (Object obj : (Iterable) o) {
ret.merge(obj, 1, (k, one) -> k + one);
}
}
}
return ret;
}
}
代码示例来源:origin: apache/metron
@Override
@SuppressWarnings("unchecked")
public Object apply(List<Object> list) {
if (list.size() < 1) {
return null;
}
LinkedHashMap<Object, Integer> ret = (LinkedHashMap<Object, Integer>)list.get(0);
if (ret == null) {
ret = new LinkedHashMap<>();
}
for (int i = 1;i < list.size();++i) {
Object o = list.get(i);
if (o != null) {
ret.merge(o, 1, (k, one) -> k + one);
}
}
return ret;
}
}
代码示例来源:origin: apache/metron
@Override
@SuppressWarnings("unchecked")
public Object apply(List<Object> list) {
if (list.size() < 1) {
return null;
}
LinkedHashMap<Object, Integer> ret = new LinkedHashMap<>();
Iterable<Map<Object, Integer>> maps = (Iterable<Map<Object, Integer>>) list.get(0);
for (Map<Object, Integer> s : maps) {
if (s != null) {
for (Map.Entry<Object, Integer> kv : s.entrySet()) {
ret.merge(kv.getKey(), kv.getValue(), (k, cnt) -> k + cnt);
}
}
}
return ret;
}
}
代码示例来源:origin: com.ca.apim.gateway/gateway-export-plugin
@Override
public synchronized Object merge(Object key, Object value, BiFunction<? super Object, ? super Object, ?> remappingFunction) {
return propertyMap.merge(key, value, remappingFunction);
}
}
代码示例来源:origin: com.google.javascript/closure-compiler
private void record(String property, PropertyAccessKind kind) {
properties.merge(property, kind, PropertyAccessKind::unionWith);
}
代码示例来源:origin: making/spring-boot-db-samples
private static Collector<PizzaView, ?, List<Pizza>> toPizzaList() {
BiConsumer<LinkedHashMap<Long, Pizza>, PizzaView> accumulator = (acc, pv) -> {
Topping t = new Topping(pv.toppingId);
t.setName(pv.toppingName);
Pizza p = acc.computeIfAbsent(pv.id, pv::toPizza);
p.getToppings().add(t);
acc.put(pv.id, p);
};
return Collector.of(LinkedHashMap::new, accumulator, (l, r) -> {
r.forEach((key, value) -> l.merge(key, value, (p1, p2) -> {
p1.getToppings().addAll(p2.getToppings());
return p1;
}));
return l;
}, map -> new ArrayList<>(map.values()));
}
内容来源于网络,如有侵权,请联系作者删除!