Class JavaPackage

java.lang.Object
uno.anahata.asi.nb.tools.project.components.ProjectNode
uno.anahata.asi.nb.tools.project.components.JavaPackage
All Implemented Interfaces:
Serializable

public final class JavaPackage extends ProjectNode
A domain object representing a logical Java package within a project.

This class handles the logical grouping of Java types and is responsible for rendering the package header with the 📦 icon and managing the summarized view of its contents.

Author:
Anahata
See Also:
  • Field Details

    • name

      private String name
      The fully qualified name of the Java package.
    • components

      private List<ProjectComponent> components
      The list of top-level Java components (types) contained within this package.
  • Constructor Details

    • JavaPackage

      public JavaPackage()
  • Method Details

    • addComponent

      public void addComponent(ProjectComponent component)
      Adds a top-level Java component to this package.
      Parameters:
      component - The component to add.
    • getTotalSize

      public long getTotalSize()
      Calculates the total recursive size of this node and all its descendants.

      Implementation details: This method must perform a deep traversal of the subtree rooted at this node, summing the sizes of all constituent physical files or logical components to provide an accurate total byte count for the branch.

      Implementation details: Iterates through all registered components and sums their results from ProjectComponent.getTotalSize().

      Specified by:
      getTotalSize in class ProjectNode
      Returns:
      The total size in bytes.
    • renderMarkdown

      public void renderMarkdown(StringBuilder sb, String indent, boolean summary)
      Renders the node and its children into a Markdown representation.

      Implementation details: The renderer must strictly honor the 'summary' flag. In summary mode, it should only output aggregate totals for the node. In standard mode, it must perform a hierarchical traversal, using indentation to represent nesting depth and specialized icons to denote node types.

      Implementation details: 1. Renders the package name prefixed with the 📦 icon. 2. In 'summary' mode, appends aggregate totals by component type (e.g. 2 CLASS, 1 png) and size. 3. In standard mode, sorts components (ensuring package-info is first) and recursively triggers their rendering logic.

      Specified by:
      renderMarkdown in class ProjectNode
      Parameters:
      sb - The target StringBuilder to append the Markdown to.
      indent - The current indentation string (e.g., " ") for nesting level.
      summary - If true, renders only the condensed/aggregate view.