static AutoCloseable tempMapPutStrictlyOrFail(Map map, A key, B value) {
if (!(map != null && key != null && value != null)) null;
B old = map.get(key);
if (old == null) {
map.put(key, value);
ret -> map.remove(old);
}
if (eq(old, value)) null;
fail("Can't overwrite key " + key + " (old value: " + old + ", new value: " + value);
}