Package org.beryx.textio
Class BooleanInputReader
- java.lang.Object
-
- org.beryx.textio.InputReader<java.lang.Boolean,BooleanInputReader>
-
- org.beryx.textio.BooleanInputReader
-
public class BooleanInputReader extends InputReader<java.lang.Boolean,BooleanInputReader>
A reader for boolean values. Allows configuring which string value should be interpreted as true and which as false.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.beryx.textio.InputReader
InputReader.ErrorMessagesProvider, InputReader.InvalidIndexErrorMessagesProvider, InputReader.ParseResult<T>, InputReader.ValueChecker<T>
-
-
Field Summary
-
Fields inherited from class org.beryx.textio.InputReader
defaultValue, equalsFunc, inlinePossibleValues, inputMasking, inputTrimming, invalidIndexErrorMessagesProvider, itemName, numberedPossibleValues, parseErrorMessagesProvider, possibleValues, promptAdjustments, propertiesConfigurator, PROPS_PREFIX_ERROR_MESSAGE, textTerminalSupplier, valueCheckers, valueFormatter, valueListCheckers
-
-
Constructor Summary
Constructors Constructor Description BooleanInputReader(java.util.function.Supplier<TextTerminal<?>> textTerminalSupplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.List<java.lang.String>
getDefaultErrorMessages(java.lang.String s)
If noInputReader.parseErrorMessagesProvider
exists, this method is used to provide the list of error messages for the input strings
.protected InputReader.ParseResult<java.lang.Boolean>
parse(java.lang.String s)
Parses the input stringprotected void
printPrompt(java.util.List<java.lang.String> prompt, TextTerminal<?> textTerminal)
Displays a prompt inviting the user to enter a value.BooleanInputReader
withFalseInput(java.lang.String falseInput)
Configures the string value that corresponds to false.BooleanInputReader
withTrueInput(java.lang.String trueInput)
Configures the string value that corresponds to true.-
Methods inherited from class org.beryx.textio.InputReader
checkConfiguration, executeWithTerminal, getDefaultErrorMessage, getErrorMessages, getPossibleValue, isPossibleValue, isValueListMode, noDuplicatesChecker, nonEmptyListChecker, parseAndCheck, read, read, readList, readList, readWithPrompt, withDefaultValue, withEqualsFunc, withInlinePossibleValues, withInlinePossibleValues, withInputMasking, withInputTrimming, withInvalidIndexErrorMessagesProvider, withItemName, withNumberedPossibleValues, withNumberedPossibleValues, withParseErrorMessagesProvider, withPossibleValues, withPossibleValues, withPromptAdjustments, withPropertiesConfigurator, withPropertiesPrefix, withValueChecker, withValueFormatter, withValueListChecker
-
-
-
-
Constructor Detail
-
BooleanInputReader
public BooleanInputReader(java.util.function.Supplier<TextTerminal<?>> textTerminalSupplier)
-
-
Method Detail
-
withTrueInput
public BooleanInputReader withTrueInput(java.lang.String trueInput)
Configures the string value that corresponds to true.
-
withFalseInput
public BooleanInputReader withFalseInput(java.lang.String falseInput)
Configures the string value that corresponds to false.
-
getDefaultErrorMessages
protected java.util.List<java.lang.String> getDefaultErrorMessages(java.lang.String s)
Description copied from class:InputReader
If noInputReader.parseErrorMessagesProvider
exists, this method is used to provide the list of error messages for the input strings
. It should return a non-empty list of messages.- Overrides:
getDefaultErrorMessages
in classInputReader<java.lang.Boolean,BooleanInputReader>
-
parse
protected InputReader.ParseResult<java.lang.Boolean> parse(java.lang.String s)
Description copied from class:InputReader
Parses the input string- Specified by:
parse
in classInputReader<java.lang.Boolean,BooleanInputReader>
- Parameters:
s
- the input string- Returns:
- a
InputReader.ParseResult
that holds the parsed value and/or the error messages, if errors occurred.
-
printPrompt
protected void printPrompt(java.util.List<java.lang.String> prompt, TextTerminal<?> textTerminal)
Description copied from class:InputReader
Displays a prompt inviting the user to enter a value.- Overrides:
printPrompt
in classInputReader<java.lang.Boolean,BooleanInputReader>
- Parameters:
prompt
- the list of prompt messages. May be null.textTerminal
- the text terminal to which the messages are sent.
-
-