All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.jinghui70.rainbow.utils.TreeUtils Maven / Gradle / Ivy

There is a newer version: 5.2.11
Show newest version
package io.github.jinghui70.rainbow.utils;

import cn.hutool.core.collection.CollUtil;

import java.util.List;
import java.util.function.Consumer;

public class TreeUtils {

    public static > void traverse(T treeNode, Consumer consumer) {
        if (treeNode == null) return;
        consumer.accept(treeNode);
        traverse(treeNode.getChildren(), consumer);
    }

    public static > void traverse(List tree, Consumer consumer) {
        if (CollUtil.isEmpty(tree)) return;
        for (T node : tree) {
            traverse(node, consumer);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy