Class DefaultTextBuilder

  • All Implemented Interfaces:
    BaseBuilder<TextBuilder>, TextBuilder

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

      Constructors 
      Constructor Description
      DefaultTextBuilder​(PromptBuilder parent)
      Create a new DefaultTextBuilder with the given parent.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      PromptBuilder addPrompt()
      Add this text to the parent builder.
      TextBuilder filter​(java.util.function.Function<java.lang.String,​java.lang.String> filter)
      Set a filter function that modifies the actual returned value.
      TextBuilder message​(java.lang.String message)
      Set the message for this text display.
      TextBuilder name​(java.lang.String name)
      Set the name of this text.
      TextBuilder text​(java.lang.String text)
      Set the text to display.
      TextBuilder 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

      • DefaultTextBuilder

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

      • name

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

        public TextBuilder text​(java.lang.String text)
        Set the text to display.
        Specified by:
        text in interface TextBuilder
        Parameters:
        text - the text
        Returns:
        this builder
      • message

        public TextBuilder message​(java.lang.String message)
        Set the message for this text display.
        Specified by:
        message in interface BaseBuilder<TextBuilder>
        Parameters:
        message - the message
        Returns:
        this builder
      • transformer

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

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