Commit d676584c authored by panwangnan's avatar panwangnan

NullPointExection Bug Fix

parent 2d444035
......@@ -76,14 +76,14 @@ public class TreeUtils {
public static <T, E> List<E> buildNodeList(Collection<T> tree, Function<T, Collection<T>> childGetter, Function<T, E> mapper) {
List<E> nodes = new ArrayList<>();
if (CollectionUtils.isEmpty(tree)) {
return nodes;
}
doBuildNodeList(tree, childGetter, mapper, nodes);
return nodes;
}
private static <E, T> void doBuildNodeList(Collection<T> tree, Function<T, Collection<T>> childGetter, Function<T, E> mapper, List<E> nodes) {
if (CollectionUtils.isEmpty(tree)) {
return;
}
tree.forEach(node -> {
nodes.add(mapper.apply(node));
doBuildNodeList(childGetter.apply(node), childGetter, mapper, nodes);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment