public abstract class ComparableInputReader<T extends Comparable<T>,B extends ComparableInputReader<T,B>> extends InputReader<T,B>
Comparable
.
Allows configuring the minimum and maximum permitted values.InputReader.ErrorMessageProvider, InputReader.ParseResult<T>
Modifier and Type | Field and Description |
---|---|
protected T |
maxVal |
protected T |
minVal |
defaultValue, errorMessageProvider, inputMasking, inputTrimming, numberedPossibleValues, possibleValues, propertyName, textTerminalSupplier, valueFormatter
Constructor and Description |
---|
ComparableInputReader(Supplier<TextTerminal> textTerminalSupplier) |
Modifier and Type | Method and Description |
---|---|
void |
checkConfiguration()
In addition to the checks performed by
InputReader.checkConfiguration() , it checks if minVal <= defaultVal <= maxVal |
protected List<String> |
getDefaultErrorMessage(String s)
If no errorMessageProvider exists, this method is used to provide the list of error messages for the input string s.
|
boolean |
isInRange(T val)
Returns true if minVal <= val <= maxVal
|
protected abstract String |
typeNameWithIndefiniteArticle() |
B |
withMaxVal(T maxVal)
Configures the maximum allowed value
|
B |
withMinVal(T minVal)
Configures the minimum allowed value
|
getDefaultErrorMessage, getErrorMessage, parse, printPrompt, read, read, withDefaultValue, withErrorMessageProvider, withInputMasking, withInputTrimming, withNumberedPossibleValues, withPossibleValues, withPossibleValues, withPropertyName, withValueFormatter
protected T extends Comparable<T> minVal
protected T extends Comparable<T> maxVal
public ComparableInputReader(Supplier<TextTerminal> textTerminalSupplier)
protected abstract String typeNameWithIndefiniteArticle()
protected List<String> getDefaultErrorMessage(String s)
InputReader
getDefaultErrorMessage
in class InputReader<T extends Comparable<T>,B extends ComparableInputReader<T,B>>
public void checkConfiguration() throws IllegalArgumentException
InputReader.checkConfiguration()
, it checks if minVal <= defaultVal <= maxValcheckConfiguration
in class InputReader<T extends Comparable<T>,B extends ComparableInputReader<T,B>>
IllegalArgumentException
public boolean isInRange(T val)