protected boolean promptBoolean(final String prompt,final Optional<Boolean> defaultValue) throws IOException {
  requireNonNull(prompt);
  requireNonNull(defaultValue);
  final ConsoleReader reader=getReader();
  reader.setPrompt(prompt);
  Boolean value=null;
  boolean prompting=true;
  while (prompting) {
    final String input=reader.readLine();
    if (input.isEmpty() && defaultValue.isPresent()) {
      value=defaultValue.get();
      prompting=false;
    }
    if (isAffirmative(input)) {
      value=true;
      prompting=false;
    }
    if (isNegative(input)) {
      value=false;
      prompting=false;
    }
    if (prompting) {
      reader.println("Invalid response (true/false)");
    }
  }
  return value;
}

protected boolean promptBoolean ( final String prompt , final Optional < Boolean > defaultValue ) throws IOException { requireNonNull ( prompt ) ; requireNonNull ( defaultValue ) ; final ConsoleReader reader = getReader ( ) ; reader . setPrompt ( prompt ) ; Boolean value = null ; boolean prompting = true ; while ( prompting ) { final String input = reader . readLine ( ) ; if ( input . isEmpty ( ) && defaultValue . isPresent ( ) ) { value = defaultValue . get ( ) ; prompting = false ; } if ( isAffirmative ( input ) ) { value = true ; prompting = false ; } if ( isNegative ( input ) ) { value = false ; prompting = false ; } if ( prompting ) { reader . println ( "Invalid response (true/false)" ) ; } } return value ; }
prompts a user for a boolean value . the prompt will be repeated until a value true / false string has been submitted . if a default value is provided , then it will be used if the user doens ' t enter anything .
