io.github.mike10004.nanochamp.server.MultimapShim Maven / Gradle / Ivy
package io.github.mike10004.nanochamp.server;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
class MultimapShim {
private MultimapShim() {
}
public static Map> create() {
return new HashMap>();
}
public static void put(Map> map, K key, V value) {
map.computeIfAbsent(key, k -> new ArrayList<>()).add(value);
}
public static Map> copyOf(List> list) {
Map> m = create();
list.forEach(entry -> {
put(m, entry.getKey(), entry.getValue());
});
return m;
}
}