Package org.beryx.textio
Class ComparableInputReader<T extends java.lang.Comparable<T>,B extends ComparableInputReader<T,B>>
- java.lang.Object
-
- org.beryx.textio.InputReader<T,B>
-
- org.beryx.textio.ComparableInputReader<T,B>
-
- Direct Known Subclasses:
ByteInputReader
,CharInputReader
,DoubleInputReader
,FloatInputReader
,IntInputReader
,LongInputReader
,ShortInputReader
public abstract class ComparableInputReader<T extends java.lang.Comparable<T>,B extends ComparableInputReader<T,B>> extends InputReader<T,B>
A reader for values of y type that implementsComparable
. Allows configuring the minimum and maximum permitted values.
-
-
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 Modifier and Type Field Description protected T
maxVal
protected T
minVal
-
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 ComparableInputReader(java.util.function.Supplier<TextTerminal<?>> textTerminalSupplier)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
checkConfiguration()
In addition to the checks performed byInputReader.checkConfiguration()
, it checks if minVal <= maxValprotected java.util.List<java.lang.String>
getMinMaxErrorMessage(T val)
boolean
isInRange(T val)
Returns true if minVal <= val <= maxValprotected abstract java.lang.String
typeNameWithIndefiniteArticle()
B
withMaxVal(T maxVal)
Configures the maximum allowed valueB
withMinVal(T minVal)
Configures the minimum allowed value-
Methods inherited from class org.beryx.textio.InputReader
executeWithTerminal, getDefaultErrorMessage, getDefaultErrorMessages, getErrorMessages, getPossibleValue, isPossibleValue, isValueListMode, noDuplicatesChecker, nonEmptyListChecker, parse, 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
-
ComparableInputReader
public ComparableInputReader(java.util.function.Supplier<TextTerminal<?>> textTerminalSupplier)
-
-
Method Detail
-
typeNameWithIndefiniteArticle
protected abstract java.lang.String typeNameWithIndefiniteArticle()
-
getMinMaxErrorMessage
protected java.util.List<java.lang.String> getMinMaxErrorMessage(T val)
-
checkConfiguration
public void checkConfiguration() throws java.lang.IllegalArgumentException
In addition to the checks performed byInputReader.checkConfiguration()
, it checks if minVal <= maxVal- Overrides:
checkConfiguration
in classInputReader<T extends java.lang.Comparable<T>,B extends ComparableInputReader<T,B>>
- Throws:
java.lang.IllegalArgumentException
-
isInRange
public boolean isInRange(T val)
Returns true if minVal <= val <= maxVal
-
-