Package com.siperf.confio.sections
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 Summary
Modifier and TypeMethodDescriptionvoidaddContentLine(String rawLine, String trimmed, String comment) Adds a content line with parsing logic.voidaddRawLine(String line) Adds a raw line to the section.booleanaddSubsection(SectionBuilder subsection) Adds a subsection to this section builder.build()Builds the Section instance.getId()Gets the section identifier.Returns the parent section builder.Gets the section name.getSubsection(SectionId subsectionId) Returns a subsection by its identifier.getSubsection(String subsectionName) Returns a direct subsection by its name (first part of the identifier).Returns an ordered list of all subsections contained in this section.booleanhasSubsection(SectionId subsectionId) Checks if this section contains a subsection with the specified ID.booleanhasSubsection(String subsectionName) Checks if this section contains a direct subsection with the specified name.booleanisRoot()Checks if the specified section builder is a root element.voidsetParent(SectionBuilder parent) Sets the parent section builder.
-
Method Details
-
addRawLine
Adds a raw line to the section.- Parameters:
line- the raw line to add
-
addContentLine
Adds a content line with parsing logic.- Parameters:
rawLine- the raw linetrimmed- the line content without commentscomment- 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
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
Checks if this section contains a subsection with the specified ID.- Parameters:
subsectionId- the subsection identifier- Returns:
- true if the subsection builder exists
-
hasSubsection
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
Returns a subsection by its identifier.- Parameters:
subsectionId- the subsection identifier- Returns:
- subsection builder or null if not found
-
getSubsection
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
Sets the parent section builder.- Parameters:
parent- the parent section builder or null if this is a root section
-