优化代码

dev
ZhouXY108 2024-05-28 09:35:04 +08:00
parent d3b19c6cb0
commit 9ccb12f956
2 changed files with 5 additions and 12 deletions

View File

@ -57,9 +57,7 @@ public abstract class AbstractMapWrapper<K, V, T extends AbstractMapWrapper<K, V
}
public final T putAll(Map<? extends K, ? extends V> m) {
for (Entry<? extends K, ? extends V> entry : m.entrySet()) {
put(entry.getKey(), entry.getValue());
}
m.forEach(this::put);
return getSelf();
}
@ -183,9 +181,7 @@ public abstract class AbstractMapWrapper<K, V, T extends AbstractMapWrapper<K, V
}
public Builder<K, V, T> putAll(Map<? extends K, ? extends V> m) {
for (Entry<? extends K, ? extends V> entry : m.entrySet()) {
put(entry.getKey(), entry.getValue());
}
m.forEach(this::put);
return this;
}

View File

@ -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 <T, E extends Throwable> void checkAllNotNull(Iterable<T> values) throws E {
Preconditions.checkNotNull(values);
for (T item : values) {
Preconditions.checkNotNull(item);
}
values.forEach(Preconditions::checkNotNull);
}
@SafeVarargs
public static <T, E extends Throwable> void checkAllNotNull(T... values) throws E {
Preconditions.checkNotNull(values);
for (T item : values) {
Preconditions.checkNotNull(item);
}
Arrays.stream(values).forEach(Preconditions::checkNotNull);
}
private PreconditionsExt() {