@Component public class ConsoleUserInput extends Object implements UserInput
UserInput
that uses Standard in and out.Constructor and Description |
---|
ConsoleUserInput() |
Modifier and Type | Method and Description |
---|---|
String |
prompt(String prompt,
String defaultValue,
boolean echo)
Display a prompt text to the user and expect them to enter a free-form value.
|
String |
promptWithOptions(String prompt,
String defaultValue,
String... options)
Loops until one of the
options is provided. |
public String promptWithOptions(String prompt, String defaultValue, String... options)
options
is provided. Pressing return is equivalent
to returning defaultValue
.promptWithOptions
in interface UserInput
prompt
- the a message to prompt the user withdefaultValue
- the default value to be returned if the user simply presses
Enteroptions
- valid input option setpublic String prompt(String prompt, String defaultValue, boolean echo)
UserInput
prompt
in interface UserInput
prompt
- the a message to prompt the user withdefaultValue
- the default value to be returned if the user simply presses
Enterecho
- echo the input to output (set to false for sensitive input, e.g.
passwords)Copyright © 2024 Pivotal Software, Inc.. All rights reserved.