Class Section.Builder

Enclosing class:
Section

public static final class Section.Builder extends Entry.Builder<Section.Builder>
Builds a Section; from Section.builder(String). Also has the options every entry has (Entry.Builder).
  • Method Details

    • title

      public Section.Builder title(Supplier<Text> title)
      The section's title, re-read on every refresh. Required.
      Parameters:
      title - read on refresh
      Returns:
      this builder
    • title

      public Section.Builder title(Text title)
      A fixed title; see title(Supplier).
      Parameters:
      title - the title
      Returns:
      this builder
    • collapsible

      public Section.Builder collapsible(boolean collapsible)
      Whether the player can expand and collapse the section; true by default. A section that can't collapse is a titled group, always expanded, with a plain Label header.
      Parameters:
      collapsible - whether it can collapse
      Returns:
      this builder
    • expanded

      public Section.Builder expanded(boolean expanded)
      Whether a collapsible section starts expanded; false (collapsed) by default. Pass a remembered state here and save it in onToggle to keep sections as the player left them.
      Parameters:
      expanded - the initial state
      Returns:
      this builder
    • onToggle

      public Section.Builder onToggle(Consumer<Boolean> onToggle)
      Called with the new state (true = expanded) each time the section is expanded or collapsed, e.g. to remember it. Optional.
      Parameters:
      onToggle - receives the new state, on the main thread
      Returns:
      this builder
    • add

      public Section.Builder add(Entry entry)
      Appends a child entry. Children appear under the section's header, in the order added.
      Parameters:
      entry - any entry except a Section; must not be in another section
      Returns:
      this builder
      Throws:
      IllegalStateException - if entry is null or a section
    • add

      public Section.Builder add(StringListEditor editor)
      Appends a StringListEditor's entries as children.
      Parameters:
      editor - the editor
      Returns:
      this builder
    • build

      public Section build()
      Builds the section and attaches its children to it.
      Returns:
      the section
      Throws:
      IllegalStateException - if the title is missing or a child already is in another section