/** In addition to the checks performed by {@link InputReader#checkConfiguration()}, it checks if minVal <= maxVal */ @Override protected void checkConfiguration() throws IllegalArgumentException { super.checkConfiguration(); if(minLength > 0 && maxLength > 0 && minLength > maxLength) throw new IllegalArgumentException("minLength = " + minLength + ", maxLength = " + maxLength); }
/** In addition to the checks performed by {@link InputReader#checkConfiguration()}, it checks if minVal <= maxVal */ @Override public void checkConfiguration() throws IllegalArgumentException { super.checkConfiguration(); if(minVal != null && maxVal != null && minVal.compareTo(maxVal) > 0) throw new IllegalArgumentException("minVal = " + minVal + ", maxVal = " + maxVal); }
/** * Reads a value of type T. * It repeatedly prompts the user to enter a value, until a valid input string is provided. * @param prompt the list of messages to be displayed for prompting the user to enter the value * @return the value of type T parsed from the input string */ public T read(List<String> prompt) { valueListMode = false; checkConfiguration(); return executeWithTerminal(textTerminal -> { while(true) { String sVal = readWithPrompt(textTerminal, prompt); if(sVal != null && inputTrimming) sVal = sVal.trim(); if(sVal == null || sVal.isEmpty()) { if(defaultValue != null) return defaultValue; } T value = getValueFromStringOrIndex(sVal, textTerminal); if (value != null) return value; } }); }
public List<T> readList(List<String> prompt) { valueListMode = true; checkConfiguration(); return executeWithTerminal(textTerminal -> { mainLoop: