Interface Treeable<T,ID>

Type Parameters:
T - the node type | 节点类型
ID - the ID type | ID类型
All Known Implementing Classes:
DefaultTreeNode, VirtualTree

public interface Treeable<T,ID>
Treeable Interface 可树化接口

Interface for objects that can be organized into a tree structure.

可组织成树形结构的对象接口。

Features | 主要功能:

  • Define tree node contract with ID and parent ID - 定义带ID和父ID的树节点契约
  • Children list management - 子节点列表管理
  • Compatible with OpenTree operations - 兼容OpenTree操作

Usage Examples | 使用示例:

// Implement Treeable - 实现Treeable
public class Department implements Treeable<Department, Long> {
    private Long id;
    private Long parentId;
    private List<Department> children;
    // implement getId(), getParentId(), getChildren(), setChildren()
}

Security | 安全性:

  • Thread-safe: Depends on implementation - 线程安全: 取决于实现
  • Null-safe: Depends on implementation - 空值安全: 取决于实现
Since:
JDK 25, opencode-base-tree V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the children list 获取子节点列表
    Get the node ID 获取节点ID
    Get the parent node ID 获取父节点ID
    void
    setChildren(List<T> children)
    Set the children list 设置子节点列表
  • Method Details

    • getId

      ID getId()
      Get the node ID 获取节点ID
      Returns:
      the ID | ID
    • getParentId

      ID getParentId()
      Get the parent node ID 获取父节点ID
      Returns:
      the parent ID | 父节点ID
    • getChildren

      List<T> getChildren()
      Get the children list 获取子节点列表
      Returns:
      the children | 子节点列表
    • setChildren

      void setChildren(List<T> children)
      Set the children list 设置子节点列表
      Parameters:
      children - the children | 子节点列表