com.neko233.toolchain.common.base.MapUtils233 Maven / Gradle / Ivy
package com.neko233.toolchain.common.base;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MapUtils233 {
private MapUtils233() {
}
public static boolean isEmpty(final Map, ?> map) {
return map == null || map.isEmpty();
}
public static boolean isNotEmpty(final Map, ?> collection) {
return !isEmpty(collection);
}
public static void putDataIntoList(Map> map, K key, V data) {
List dataList = map.computeIfAbsent(key, k -> new ArrayList());
dataList.add(data);
}
public static Map of(Object... objs) {
if (objs == null) {
return new HashMap<>(0);
}
if (objs.length % 2 != 0) {
throw new IllegalArgumentException("your map data is not 2 Multiple ratio");
}
Map map = new HashMap<>(objs.length / 2);
for (int i = 0; i < objs.length; i += 2) {
map.put((K) objs[i], (V) objs[i + 1]);
}
return map;
}
}