interface TreeVisitor {
/**
* 访问函数
*
* @param t 访问对象(树节点)
*/
void visit(ItemVO t);
}
/**
* 访问者模式,递归遍历树节点
*
* @param t 树节点
* @param visitor 访问者
*/
private static void visitTree(ItemVO t, TreeVisitor visitor) {
visitor.visit(t);
if (null != t.children) {
for (ItemVO child : t.children) {
visitTree(child, visitor);
}
}
}
Kotlin developer community
Related Topics domestic first Kotlin developer community public numbers, the main share exchange Kotlin programming language, Spring Boot, Android, React.js / Node.js, functional programming, programming ideas and so on.
The more hustle and bustle of the world, the more you need quiet to think.