Class ComparisonModule

All Implemented Interfaces:
Component

public class ComparisonModule extends Module
Module for side-by-side comparison tables.

Mutability and thread-safety: mutable and not thread-safe. Column and row collections are mutable and consumed during build; mutate within a request-scoped flow. For reuse, stop mutating and render as a stable structure with per-request slot/context values.

  • Constructor Details

    • ComparisonModule

      public ComparisonModule()
  • Method Details

    • create

      public static ComparisonModule create()
    • withTitle

      public ComparisonModule withTitle(String title)
      Description copied from class: Module
      Sets optional title consumed by Module.buildContent() implementations.
      Overrides:
      withTitle in class Module
    • withModuleId

      public ComparisonModule withModuleId(String moduleId)
      Description copied from class: Module
      Sets module id and synchronizes the underlying id attribute.
      Overrides:
      withModuleId in class Module
    • addColumn

      public ComparisonModule addColumn(String name)
      Adds a comparison column.
      Parameters:
      name - the column name/header
    • addColumn

      public ComparisonModule addColumn(String name, boolean highlighted)
      Adds a comparison column with optional highlighting.
      Parameters:
      name - the column name/header
      highlighted - whether to highlight this column (e.g., "recommended")
    • addRow

      public ComparisonModule addRow(String label, String... values)
      Adds a comparison row with string values for each column.
      Parameters:
      label - the row label (attribute name)
      values - values for each column (must match column count)
    • addRowWithComponents

      public ComparisonModule addRowWithComponents(String label, Component... values)
      Adds a comparison row with custom component values.
      Parameters:
      label - the row label (attribute name)
      values - custom components for each column
    • buildContent

      protected void buildContent()
      Description copied from class: Module
      Composes module structure.

      Called at most once by Module.build() unless Module.rebuildContent() is invoked. Do not rely on this method for per-request mutation.

      Specified by:
      buildContent in class Module