调整集合相关工具类。

This commit is contained in:
2024-02-07 09:27:42 +08:00
parent 81c5b6972a
commit 5cee71a342
8 changed files with 302 additions and 206 deletions

View File

@@ -0,0 +1,17 @@
package xyz.zhouxy.plusone.commons.collection;
import java.util.Map;
import java.util.function.Function;
public class MapTools {
public static <K, V> void transformValue(Map<K, V> map, K key, Function<V, ? extends V> func) {
if (map.containsKey(key)) {
map.put(key, func.apply(map.get(key)));
}
}
private MapTools() {
throw new IllegalStateException("Utility class");
}
}