Package io.sundr.utils
Class Dependencies.DependencyTree<T>
java.lang.Object
io.sundr.utils.Dependencies.DependencyTree<T>
- Type Parameters:
T- the type of items in this dependency tree
- Enclosing class:
- Dependencies
A dependency tree that tracks relationships between items and can render them
in a visual tree format. Supports cycle detection and custom formatting.
-
Method Summary
Modifier and TypeMethodDescriptionfinal Dependencies.DependencyTree<T>addDependency(T item, T... dependencies) Adds an item with its direct dependencies to the tree.Gets all nodes in the dependency tree.render()Renders the entire dependency tree as a formatted string.renderFrom(T root) Renders a subtree starting from the specified root node.withFormatter(Function<T, String> formatter) Sets a custom formatter for rendering items.
-
Method Details
-
addDependency
Adds an item with its direct dependencies to the tree.- Parameters:
item- the item to adddependencies- the direct dependencies of the item- Returns:
- this DependencyTree for method chaining
- Throws:
NullPointerException- if item is null
-
withFormatter
Sets a custom formatter for rendering items.- Parameters:
formatter- function to convert items to string representation- Returns:
- this DependencyTree for method chaining
-
getAllNodes
Gets all nodes in the dependency tree.- Returns:
- a set containing all nodes that have been added to this tree
-
render
Renders the entire dependency tree as a formatted string. Shows all root nodes and their dependencies in tree format.- Returns:
- a string representation of the dependency tree
-
renderFrom
Renders a subtree starting from the specified root node.- Parameters:
root- the root node to start rendering from- Returns:
- a string representation of the subtree
- Throws:
NullPointerException- if root is null
-