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.ErrorMessagesProvider, InputReader.ParseResult<T>, InputReader.ValueChecker<T>
Modifier and Type | Field and Description |
---|---|
protected T |
maxVal |
protected T |
minVal |
defaultValue, equalsFunc, inputMasking, inputTrimming, numberedPossibleValues, parseErrorMessagesProvider, possibleValues, promptAdjustments, propertyName, textTerminalSupplier, valueCheckers, valueFormatter, valueListCheckers
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 <= maxVal |
protected List<String> |
getMinMaxErrorMessage(T val) |
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, getDefaultErrorMessages, getErrorMessages, isPossibleValue, isValueListMode, noDuplicatesChecker, nonEmptyListChecker, parse, parseAndCheck, printPrompt, read, read, readList, readList, withDefaultValue, withEqualsFunc, withInputMasking, withInputTrimming, withNumberedPossibleValues, withParseErrorMessagesProvider, withPossibleValues, withPossibleValues, withPromptAdjustments, withPropertyName, withValueChecker, withValueFormatter, withValueListChecker
protected T extends Comparable<T> minVal
protected T extends Comparable<T> maxVal
public ComparableInputReader(Supplier<TextTerminal> textTerminalSupplier)
protected abstract String typeNameWithIndefiniteArticle()
public void checkConfiguration() throws IllegalArgumentException
InputReader.checkConfiguration()
, it checks if minVal <= maxValcheckConfiguration
in class InputReader<T extends Comparable<T>,B extends ComparableInputReader<T,B>>
IllegalArgumentException
public boolean isInRange(T val)