mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
Update hutool-core/src/main/java/cn/hutool/core/tree/BeanTree.java
This commit is contained in:
parent
ce576a1d33
commit
f1f741bb58
@ -120,10 +120,13 @@ public class BeanTree<T, R extends Comparable<R>> {
|
||||
* @return 转换后的树
|
||||
*/
|
||||
public List<T> toTree(final List<T> list) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return ListUtil.zero();
|
||||
}
|
||||
if (Objects.isNull(parentPredicate)) {
|
||||
final Map<R, List<T>> pIdValuesMap = EasyStream.of(list)
|
||||
.peek(e -> Objects.requireNonNull(idGetter.apply(e), "The id of tree node must not be null")
|
||||
)).group(pidGetter);
|
||||
).group(pidGetter);
|
||||
final List<T> parents = pIdValuesMap.getOrDefault(pidValue, new ArrayList<>());
|
||||
findChildren(list, pIdValuesMap);
|
||||
return parents;
|
||||
|
Loading…
x
Reference in New Issue
Block a user