mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
!758 优化Opt.ofEmptyAble(), 避免无意义的判断;
Merge pull request !758 from emptypoint/v6-Opt-update
This commit is contained in:
commit
3da46bbc02
@ -31,7 +31,6 @@ import cn.hutool.core.text.StrUtil;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
@ -109,7 +108,7 @@ public class Opt<T> {
|
||||
* @since 5.7.17
|
||||
*/
|
||||
public static <T, R extends Collection<T>> Opt<R> ofEmptyAble(final R value) {
|
||||
return CollUtil.isEmpty(value) || Objects.equals(Collections.frequency(value, null), value.size()) ? empty() : new Opt<>(value);
|
||||
return CollUtil.isEmpty(value) || CollUtil.getFirstNoneNull(value) == null ? empty() : new Opt<>(value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user