Update hutool-core/src/main/java/cn/hutool/core/tree/BeanTree.java

:trollface:
This commit is contained in:
emptypoint 2022-11-28 09:48:23 +00:00 committed by Gitee
parent 01bc7e6c16
commit 39cf534006
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -129,8 +129,8 @@ public class BeanTree<T, R extends Comparable<R>> {
} }
if (Objects.isNull(parentPredicate)) { if (Objects.isNull(parentPredicate)) {
final Map<R, List<T>> pIdValuesMap = EasyStream.of(list) final Map<R, List<T>> pIdValuesMap = EasyStream.of(list)
.peek(e -> Assert.notNull(idGetter.apply(e), "The id of tree node must not be null {}", e)) .peek(e -> Objects.requireNonNull(idGetter.apply(e), () -> "The id of tree node must not be null " + e))
).group(pidGetter); .group(pidGetter);
final List<T> parents = pIdValuesMap.getOrDefault(pidValue, new ArrayList<>()); final List<T> parents = pIdValuesMap.getOrDefault(pidValue, new ArrayList<>());
findChildren(list, pIdValuesMap); findChildren(list, pIdValuesMap);
return parents; return parents;