Package org.beryx.textio
Class StringInputReader
- java.lang.Object
-
- org.beryx.textio.InputReader<java.lang.String,StringInputReader>
-
- org.beryx.textio.StringInputReader
-
public class StringInputReader extends InputReader<java.lang.String,StringInputReader>
A reader for string values. Allows configuring the minimum and maximum length, as well as a regex pattern.
-
-
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 StringInputReader(java.util.function.Supplier<TextTerminal<?>> textTerminalSupplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkConfiguration()
In addition to the checks performed byInputReader.checkConfiguration()
, it checks if minVal <= maxValprotected java.util.List<java.lang.String>
getLengthValidationErrors(java.lang.String s)
protected java.util.List<java.lang.String>
getPatternValidationErrors(java.lang.String s)
protected InputReader.ParseResult<java.lang.String>
parse(java.lang.String s)
Parses the input stringStringInputReader
withIgnoreCase()
StringInputReader
withMaxLength(int maxLength)
StringInputReader
withMinLength(int minLength)
StringInputReader
withPattern(java.lang.String regex)
StringInputReader
withPattern(java.lang.String regex, int flags)
-
Methods inherited from class org.beryx.textio.InputReader
executeWithTerminal, getDefaultErrorMessage, getDefaultErrorMessages, getErrorMessages, getPossibleValue, isPossibleValue, isValueListMode, noDuplicatesChecker, nonEmptyListChecker, parseAndCheck, printPrompt, 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
-
StringInputReader
public StringInputReader(java.util.function.Supplier<TextTerminal<?>> textTerminalSupplier)
-
-
Method Detail
-
withPattern
public StringInputReader withPattern(java.lang.String regex)
-
withPattern
public StringInputReader withPattern(java.lang.String regex, int flags)
-
withMinLength
public StringInputReader withMinLength(int minLength)
-
withMaxLength
public StringInputReader withMaxLength(int maxLength)
-
withIgnoreCase
public StringInputReader withIgnoreCase()
-
parse
protected InputReader.ParseResult<java.lang.String> parse(java.lang.String s)
Description copied from class:InputReader
Parses the input string- Specified by:
parse
in classInputReader<java.lang.String,StringInputReader>
- Parameters:
s
- the input string- Returns:
- a
InputReader.ParseResult
that holds the parsed value and/or the error messages, if errors occurred.
-
checkConfiguration
protected void checkConfiguration() throws java.lang.IllegalArgumentException
In addition to the checks performed byInputReader.checkConfiguration()
, it checks if minVal <= maxVal- Overrides:
checkConfiguration
in classInputReader<java.lang.String,StringInputReader>
- Throws:
java.lang.IllegalArgumentException
-
getLengthValidationErrors
protected java.util.List<java.lang.String> getLengthValidationErrors(java.lang.String s)
-
getPatternValidationErrors
protected java.util.List<java.lang.String> getPatternValidationErrors(java.lang.String s)
-
-