优化代码
parent
d3b19c6cb0
commit
9ccb12f956
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue