Class Prompter


  • public class Prompter
    extends java.lang.Object
    Displays prompts on the terminal to ask the user various kinds of questions.
    • Constructor Summary

      Constructors 
      Constructor Description
      Prompter​(Terminals terminals)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Boolean askYesNo​(java.lang.String prompt, boolean defaultValue)
      Asks the user a yes/no question.
      java.lang.String enterPassword​(java.lang.String prompt)
      Asks the user to enter a password.
      java.lang.String enterText​(java.lang.String prompt, java.lang.String defaultValue)
      Asks the user to enter some text.
      boolean isInteractive()
      Returns true if this prompter can ask the user questions.
      java.lang.Integer select​(java.lang.String prompt, java.util.List<java.lang.String> options, int defaultOption)
      Asks the user to select an option from a list.
      • Methods inherited from class java.lang.Object

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

      • Prompter

        public Prompter​(Terminals terminals)
    • Method Detail

      • isInteractive

        public boolean isInteractive()
        Returns true if this prompter can ask the user questions.
      • select

        public java.lang.Integer select​(java.lang.String prompt,
                                        java.util.List<java.lang.String> options,
                                        int defaultOption)
        Asks the user to select an option from a list.
        Returns:
        The index of the selected option or null on end of input. Returns the default option when not interactive.
      • enterText

        public java.lang.String enterText​(java.lang.String prompt,
                                          java.lang.String defaultValue)
        Asks the user to enter some text.
        Returns:
        The text or null on end of input. Returns the default value when not interactive.
      • enterPassword

        public java.lang.String enterPassword​(java.lang.String prompt)
        Asks the user to enter a password.
        Returns:
        The password or null on end of input or when not interactive or when not possible to prompt for a password without echoing the characters.
      • askYesNo

        public java.lang.Boolean askYesNo​(java.lang.String prompt,
                                          boolean defaultValue)
        Asks the user a yes/no question.
        Returns:
        The selected value or null on end of input. Returns the default value when not interactive.