Dict增加覆盖putIfAbsent和computeIfAbsent的方法

This commit is contained in:
gonggy 2022-07-19 09:18:46 +08:00
parent 40fab305dd
commit b83be40567

View File

@ -20,6 +20,7 @@ import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import java.util.function.Function;
/** /**
* 字典对象扩充了HashMap中的方法 * 字典对象扩充了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) { public Object merge(final String key, final Object value, final BiFunction<? super Object, ? super Object, ?> remappingFunction) {
return super.merge(customKey(key), value, 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 //---------------------------------------------------------------------------- Override default methods end
/** /**