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

This commit is contained in:
emptypoint 2022-11-27 14:31:00 +00:00 committed by Gitee
parent a631f7e915
commit d5879a0abd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

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