diff --git a/src/main/java/xyz/zhouxy/plusone/commons/collection/AbstractMapWrapper.java b/src/main/java/xyz/zhouxy/plusone/commons/collection/AbstractMapWrapper.java index 990474f..501f3b2 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/collection/AbstractMapWrapper.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/collection/AbstractMapWrapper.java @@ -123,15 +123,31 @@ public abstract class AbstractMapWrapper mappingFunction) { + if (this.keyChecker != null) { + this.keyChecker.accept(key); + } + Function func = (K k) -> { + V value = mappingFunction.apply(k); + if (this.valueChecker != null) { + this.valueChecker.accept(value); + } + return value; + }; if (this.map instanceof ConcurrentHashMap) { return ConcurrentHashMapTools.computeIfAbsent( - (ConcurrentHashMap) this.map, key, mappingFunction); + (ConcurrentHashMap) this.map, key, func); } else { - return this.map.computeIfAbsent(key, mappingFunction); + return this.map.computeIfAbsent(key, func); } } @@ -139,7 +155,7 @@ public abstract class AbstractMapWrapper exportUnmodifiableMapMap() { + public final Map exportUnmodifiableMap() { return Collections.unmodifiableMap(this.map); }