!714 Dict增加覆盖putIfAbsent和computeIfAbsent的方法

Merge pull request !714 from uyong/dict-fixed
This commit is contained in:
Looly 2022-07-19 02:27:52 +00:00 committed by Gitee
commit d8bf71513c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -20,6 +20,7 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.function.Function;
/**
* 字典对象扩充了HashMap中的方法
@ -633,6 +634,17 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
public Object merge(final String key, final Object value, final BiFunction<? super Object, ? super Object, ?> remappingFunction) {
return super.merge(customKey(key), value, remappingFunction);
}
@Override
public Object putIfAbsent(String key, Object value) {
return super.putIfAbsent(customKey(key), value);
}
@Override
public Object computeIfAbsent(String key, Function<? super String, ?> mappingFunction) {
return super.computeIfAbsent(customKey(key), mappingFunction);
}
//---------------------------------------------------------------------------- Override default methods end
/**