@Override public void run() { setChoices(choices.stream().map(Object::toString).collect(Collectors.toList())); setHistory(historyStore.getValues(key)); try { R inputReader = inputReaderSupplier.get(); if (showPrevious) inputReader.withDefaultValue(defaultValueSupplier.get()); if(inputReaderConfigurator != null) { inputReaderConfigurator.accept(inputReader); } if(constrainedInput) { inputReader.withValueChecker((val,name) -> choices.contains(val) ? null : Arrays.asList("'" + val + "' is not in the choice list.")); } T value = inputReader.read(prompt); historyStore.addValue(key, value.toString()); valueSetter.accept(value); } finally { setChoices(Collections.emptyList()); setHistory(Collections.emptyList()); } }