Interface SectionBuilder

All Known Implementing Classes:
AbstractSectionBuilder, KeyValueSectionBuilder, UppercaseSectionBuilder

public interface SectionBuilder
Builder interface for creating Section instances with custom parsing logic. Implementations can provide different parsing strategies for different section types.
  • Method Details

    • addRawLine

      void addRawLine(String line)
      Adds a raw line to the section.
      Parameters:
      line - the raw line to add
    • addContentLine

      void addContentLine(String rawLine, String trimmed, String comment)
      Adds a content line with parsing logic.
      Parameters:
      rawLine - the raw line
      trimmed - the line content without comments
      comment - the comment part (if any)
    • build

      Section build()
      Builds the Section instance.
      Returns:
      the built section
    • getSectionName

      String getSectionName()
      Gets the section name.
      Returns:
      section name
    • getId

      SectionId getId()
      Gets the section identifier.
      Returns:
      section identifier
    • isRoot

      boolean isRoot()
      Checks if the specified section builder is a root element.
      Returns:
      true if id is the root section ID
    • addSubsection

      boolean addSubsection(SectionBuilder subsection)
      Adds a subsection to this section builder.
      Parameters:
      subsection - the subsection builder to add
      Returns:
      true if subsection was added, false if subsection cannot be added
    • getSubsections

      List<SectionBuilder> getSubsections()
      Returns an ordered list of all subsections contained in this section.
      Returns:
      unmodifiable list of subsections in the order they were added
    • hasSubsection

      boolean hasSubsection(SectionId subsectionId)
      Checks if this section contains a subsection with the specified ID.
      Parameters:
      subsectionId - the subsection identifier
      Returns:
      true if the subsection builder exists
    • hasSubsection

      boolean hasSubsection(String subsectionName)
      Checks if this section contains a direct subsection with the specified name.
      Parameters:
      subsectionName - the subsection name (first part of the identifier)
      Returns:
      true if the subsection exists
    • getSubsection

      SectionBuilder getSubsection(SectionId subsectionId)
      Returns a subsection by its identifier.
      Parameters:
      subsectionId - the subsection identifier
      Returns:
      subsection builder or null if not found
    • getSubsection

      SectionBuilder getSubsection(String subsectionName)
      Returns a direct subsection by its name (first part of the identifier).
      Parameters:
      subsectionName - the subsection name
      Returns:
      subsection builder or null if not found
    • getParent

      SectionBuilder getParent()
      Returns the parent section builder.
      Returns:
      parent section builder or null if this is a root section
    • setParent

      void setParent(SectionBuilder parent)
      Sets the parent section builder.
      Parameters:
      parent - the parent section builder or null if this is a root section