Class DefaultChoiceBuilder

java.lang.Object
org.jline.prompt.impl.DefaultChoiceBuilder
All Implemented Interfaces:
BaseBuilder<ChoiceBuilder>, ChoiceBuilder

public class DefaultChoiceBuilder extends Object implements ChoiceBuilder
Default implementation of ChoiceBuilder. This is now the native implementation that doesn't depend on console-ui.
  • Constructor Details

    • DefaultChoiceBuilder

      public DefaultChoiceBuilder(PromptBuilder parent)
      Create a new DefaultChoiceBuilder with the given parent.
      Parameters:
      parent - the parent builder
  • Method Details

    • name

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

      public ChoiceBuilder message(String message)
      Set the message to display to the user.
      Specified by:
      message in interface BaseBuilder<ChoiceBuilder>
      Parameters:
      message - the message
      Returns:
      this builder
    • newChoice

      public ChoiceBuilder newChoice(String id)
      Create a new choice with the given ID.
      Specified by:
      newChoice in interface ChoiceBuilder
      Parameters:
      id - the ID
      Returns:
      this builder
    • key

      public ChoiceBuilder key(char key)
      Set the key for the current choice.
      Specified by:
      key in interface ChoiceBuilder
      Parameters:
      key - the key
      Returns:
      this builder
    • text

      public ChoiceBuilder text(String text)
      Set the text for the current choice.
      Specified by:
      text in interface ChoiceBuilder
      Parameters:
      text - the text
      Returns:
      this builder
    • helpText

      public ChoiceBuilder helpText(String helpText)
      Set the help text for the current choice.
      Specified by:
      helpText in interface ChoiceBuilder
      Parameters:
      helpText - the help text
      Returns:
      this builder
    • defaultChoice

      public ChoiceBuilder defaultChoice(boolean defaultChoice)
      Set whether the current choice is the default.
      Specified by:
      defaultChoice in interface ChoiceBuilder
      Parameters:
      defaultChoice - whether the choice is the default
      Returns:
      this builder
    • add

      public ChoiceBuilder add()
      Add the current choice to the list.
      Specified by:
      add in interface ChoiceBuilder
      Returns:
      this builder
    • transformer

      public ChoiceBuilder transformer(Function<String,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<ChoiceBuilder>
      Parameters:
      transformer - the transformer function
      Returns:
      this builder instance for method chaining
    • filter

      public ChoiceBuilder filter(Function<String,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<ChoiceBuilder>
      Parameters:
      filter - the filter function
      Returns:
      this builder instance for method chaining
    • addPrompt

      public PromptBuilder addPrompt()
      Add this prompt to the parent builder.
      Specified by:
      addPrompt in interface BaseBuilder<ChoiceBuilder>
      Returns:
      the parent PromptBuilder for continued prompt configuration
      See Also: