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 f1e6bc2..990474f 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/collection/AbstractMapWrapper.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/collection/AbstractMapWrapper.java @@ -57,9 +57,7 @@ public abstract class AbstractMapWrapper m) { - for (Entry entry : m.entrySet()) { - put(entry.getKey(), entry.getValue()); - } + m.forEach(this::put); return getSelf(); } @@ -183,9 +181,7 @@ public abstract class AbstractMapWrapper putAll(Map m) { - for (Entry entry : m.entrySet()) { - put(entry.getKey(), entry.getValue()); - } + m.forEach(this::put); return this; } diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/PreconditionsExt.java b/src/main/java/xyz/zhouxy/plusone/commons/util/PreconditionsExt.java index f18b0e4..c6ffbec 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/PreconditionsExt.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/PreconditionsExt.java @@ -16,6 +16,7 @@ package xyz.zhouxy.plusone.commons.util; +import java.util.Arrays; import java.util.function.Supplier; import com.google.common.base.Preconditions; @@ -37,17 +38,13 @@ public class PreconditionsExt { public static void checkAllNotNull(Iterable values) throws E { Preconditions.checkNotNull(values); - for (T item : values) { - Preconditions.checkNotNull(item); - } + values.forEach(Preconditions::checkNotNull); } @SafeVarargs public static void checkAllNotNull(T... values) throws E { Preconditions.checkNotNull(values); - for (T item : values) { - Preconditions.checkNotNull(item); - } + Arrays.stream(values).forEach(Preconditions::checkNotNull); } private PreconditionsExt() {