Class GoalReportBuilder

java.lang.Object
network.ike.plugin.support.GoalReportBuilder

public final class GoalReportBuilder extends Object
Fluent builder for the body of an IKE goal report.

GoalReport owns the report frame — the # <prefix>:<goal> title and the timestamp line. This builder owns the body: the sections, paragraphs, bullet lists, tables, and fenced code blocks beneath that frame. Routing every report through one builder keeps section depth, table syntax, and spacing identical across goals instead of each mojo hand-rolling its own StringBuilder (IKE-Network/ike-issues#408).

Methods return this so a report reads as a single chained expression:

String body = new GoalReportBuilder()
        .section("Status")
        .paragraph("3 cloned, 1 not cloned.")
        .table(List.of("Subproject", "Branch"),
               List.of(new String[]{"ike-docs", "main"}))
        .build();

The builder emits GitHub-flavoured Markdown. Section headings use ## — one level below the # title GoalReport prepends. Pass the build() result to AbstractGoalMojo.writeReport (ike plugin) or AbstractWorkspaceMojo.writeReport (ws plugin).

  • Constructor Details

    • GoalReportBuilder

      public GoalReportBuilder()
      Creates an empty report-body builder.
  • Method Details

    • section

      public GoalReportBuilder section(String title)
      Append a section heading (## title).
      Parameters:
      title - the section title
      Returns:
      this builder
    • paragraph

      public GoalReportBuilder paragraph(String text)
      Append a paragraph followed by a blank line.
      Parameters:
      text - the paragraph text
      Returns:
      this builder
    • bullet

      public GoalReportBuilder bullet(String text)
      Append a single bullet-list item (- text). Consecutive calls build a contiguous list.
      Parameters:
      text - the bullet text
      Returns:
      this builder
    • table

      public GoalReportBuilder table(List<String> headers, List<String[]> rows)
      Append a GitHub-flavoured Markdown table. A no-op when rows is empty — an empty table is never emitted.
      Parameters:
      headers - column headers (defines the column count)
      rows - row cells; each array should match the header count (shorter rows are padded, longer rows truncated, so a ragged caller cannot break the table grid)
      Returns:
      this builder
    • codeBlock

      public GoalReportBuilder codeBlock(String language, String content)
      Append a fenced code block.
      Parameters:
      language - the fence language hint (e.g. "dot"); may be empty for a plain fence
      content - the block content (a trailing newline is added if absent)
      Returns:
      this builder
    • raw

      public GoalReportBuilder raw(String markdown)
      Append a pre-rendered Markdown fragment verbatim — the escape hatch for content a primitive does not cover (e.g. DriftReport.toMarkdown()).
      Parameters:
      markdown - the Markdown fragment
      Returns:
      this builder
    • build

      public String build()
      Render the accumulated body as a Markdown string.
      Returns:
      the report body (no title or timestamp — those are added by GoalReport)