Class DefaultListBuilder

  • All Implemented Interfaces:
    BaseBuilder<ListBuilder>, ListBuilder

    public class DefaultListBuilder
    extends java.lang.Object
    implements ListBuilder
    Default implementation of ListBuilder. This is now the native implementation that doesn't depend on console-ui.
    • Constructor Detail

      • DefaultListBuilder

        public DefaultListBuilder​(PromptBuilder parent)
        Create a new DefaultListBuilder with the given parent.
        Parameters:
        parent - the parent builder
    • Method Detail

      • name

        public ListBuilder name​(java.lang.String name)
        Set the name of this prompt.
        Specified by:
        name in interface BaseBuilder<ListBuilder>
        Parameters:
        name - the name
        Returns:
        this builder
      • message

        public ListBuilder message​(java.lang.String message)
        Set the message to display to the user.
        Specified by:
        message in interface BaseBuilder<ListBuilder>
        Parameters:
        message - the message
        Returns:
        this builder
      • newItem

        public ListBuilder newItem​(java.lang.String id)
        Create a new item with the given ID.
        Specified by:
        newItem in interface ListBuilder
        Parameters:
        id - the ID
        Returns:
        this builder
      • text

        public ListBuilder text​(java.lang.String text)
        Set the text for the current item.
        Specified by:
        text in interface ListBuilder
        Parameters:
        text - the text
        Returns:
        this builder
      • disabled

        public ListBuilder disabled​(boolean disabled)
        Set whether the current item is disabled.
        Specified by:
        disabled in interface ListBuilder
        Parameters:
        disabled - whether the item is disabled
        Returns:
        this builder
      • disabledText

        public ListBuilder disabledText​(java.lang.String disabledText)
        Set the disabled text for the current item.
        Specified by:
        disabledText in interface ListBuilder
        Parameters:
        disabledText - the disabled text
        Returns:
        this builder
      • footer

        public ListBuilder footer​(java.lang.String footer)
        Description copied from interface: ListBuilder
        Set the footer text for the current item. The footer is shown dimmed below the list while this item is focused. Newlines split it into multiple lines and long lines wrap to the terminal width; the footer pane has a fixed height so the list does not shift between items.
        Specified by:
        footer in interface ListBuilder
        Parameters:
        footer - the footer text, or null/empty for none
        Returns:
        this builder
      • add

        public ListBuilder add()
        Add the current item to the list.
        Specified by:
        add in interface ListBuilder
        Returns:
        this builder
      • filterable

        public ListBuilder filterable​(boolean filterable)
        Description copied from interface: ListBuilder
        Set whether the list supports inline text filtering. When enabled (the default), the user can type characters to filter the displayed items. When disabled, typed characters are ignored.
        Specified by:
        filterable in interface ListBuilder
        Parameters:
        filterable - true to enable filtering, false to disable
        Returns:
        this builder
      • pageSize

        public ListBuilder pageSize​(int pageSize)
        Description copied from interface: ListBuilder
        Set the page size for pagination.
        Specified by:
        pageSize in interface ListBuilder
        Parameters:
        pageSize - the page size, or 0 for no pagination
        Returns:
        this builder
      • showPageIndicator

        public ListBuilder showPageIndicator​(boolean showPageIndicator)
        Description copied from interface: ListBuilder
        Set whether to show page indicators.
        Specified by:
        showPageIndicator in interface ListBuilder
        Parameters:
        showPageIndicator - true to show page indicators
        Returns:
        this builder
      • newSeparator

        public ListSeparatorBuilder newSeparator​(java.lang.String text)
        Description copied from interface: ListBuilder
        Create a new separator with the given text.
        Specified by:
        newSeparator in interface ListBuilder
        Parameters:
        text - the separator text
        Returns:
        a separator builder
      • addSeparator

        public void addSeparator​(SeparatorItem separatorItem)
        Add a separator item to the list.
        Parameters:
        separatorItem - the separator item to add
      • transformer

        public ListBuilder transformer​(java.util.function.Function<java.lang.String,​java.lang.String> transformer)
        Description copied from interface: BaseBuilder
        Set a transformer function that modifies how the answer is displayed after submission. This does not change the actual returned value. For example, a password prompt might transform the answer to "***".
        Specified by:
        transformer in interface BaseBuilder<ListBuilder>
        Parameters:
        transformer - the transformer function
        Returns:
        this builder instance for method chaining
      • filter

        public ListBuilder filter​(java.util.function.Function<java.lang.String,​java.lang.String> filter)
        Description copied from interface: BaseBuilder
        Set a filter function that modifies the actual returned value. This changes the value stored in the result map. For example, trimming whitespace or converting to lowercase.
        Specified by:
        filter in interface BaseBuilder<ListBuilder>
        Parameters:
        filter - the filter function
        Returns:
        this builder instance for method chaining