feat: MapUtils.findAndThen,key 为 null 时, 不处理

Signed-off-by: dhb52 <dhb52@126.com>
This commit is contained in:
dhb52 2024-03-05 15:13:53 +00:00 committed by Gitee
parent e091b077a8
commit f4b1e9ca4a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -40,6 +40,7 @@ public class MapUtils {
/**
* 从哈希表查找到 key 对应的 value然后进一步处理
* key null , 不处理
* 注意如果查找到的 value null 不进行处理
*
* @param map 哈希表
@ -47,7 +48,7 @@ public class MapUtils {
* @param consumer 进一步处理的逻辑
*/
public static <K, V> void findAndThen(Map<K, V> map, K key, Consumer<V> consumer) {
if (CollUtil.isEmpty(map)) {
if (ObjUtil.isNull(key) || CollUtil.isEmpty(map)) {
return;
}
V value = map.get(key);