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

public static final class Dependencies.DependencyTree<T> extends Object
A dependency tree that tracks relationships between items and can render them in a visual tree format. Supports cycle detection and custom formatting.
  • Method Details

    • addDependency

      @SafeVarargs public final Dependencies.DependencyTree<T> addDependency(T item, T... dependencies)
      Adds an item with its direct dependencies to the tree.
      Parameters:
      item - the item to add
      dependencies - the direct dependencies of the item
      Returns:
      this DependencyTree for method chaining
      Throws:
      NullPointerException - if item is null
    • withFormatter

      public Dependencies.DependencyTree<T> withFormatter(Function<T,String> formatter)
      Sets a custom formatter for rendering items.
      Parameters:
      formatter - function to convert items to string representation
      Returns:
      this DependencyTree for method chaining
    • getAllNodes

      public Set<T> getAllNodes()
      Gets all nodes in the dependency tree.
      Returns:
      a set containing all nodes that have been added to this tree
    • render

      public String 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

      public String renderFrom(T root)
      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