Class DefaultChoiceBuilder

  • All Implemented Interfaces:
    BaseBuilder<ChoiceBuilder>, ChoiceBuilder

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ChoiceBuilder add()
      Add the current choice to the list.
      PromptBuilder addPrompt()
      Add this prompt to the parent builder.
      ChoiceBuilder defaultChoice​(boolean defaultChoice)
      Set whether the current choice is the default.
      ChoiceBuilder filter​(java.util.function.Function<java.lang.String,​java.lang.String> filter)
      Set a filter function that modifies the actual returned value.
      ChoiceBuilder helpText​(java.lang.String helpText)
      Set the help text for the current choice.
      ChoiceBuilder key​(char key)
      Set the key for the current choice.
      ChoiceBuilder message​(java.lang.String message)
      Set the message to display to the user.
      ChoiceBuilder name​(java.lang.String name)
      Set the name of this prompt.
      ChoiceBuilder newChoice​(java.lang.String id)
      Create a new choice with the given ID.
      ChoiceBuilder text​(java.lang.String text)
      Set the text for the current choice.
      ChoiceBuilder transformer​(java.util.function.Function<java.lang.String,​java.lang.String> transformer)
      Set a transformer function that modifies how the answer is displayed after submission.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultChoiceBuilder

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

      • message

        public ChoiceBuilder message​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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
      • transformer

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

        public ChoiceBuilder 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<ChoiceBuilder>
        Parameters:
        filter - the filter function
        Returns:
        this builder instance for method chaining