code: protected void assureInputFromUser(final String prompt, final String initValue, final List<String> options,
                                         final Consumer<String> setter) {
          final String option = findElementInOptions(options, initValue);
          if (option != null) {
              info(FOUND_VALID_VALUE);
              setter.accept(option);
              return;
          }
  
          out.printf("Choose from below options as %s %n", prompt);
          for (int i = 0; i < options.size(); i++) {
              out.printf("%d. %s%n", i, options.get(i));
          }
  
          assureInputFromUser("Enter index to use: ", null,
              str -> {
                  try {
                      final int index = Integer.parseInt(str);
                      return 0 <= index && index < options.size();
                  } catch (Exception e) {
                      return false;
                  }
              },
              "Invalid index.", str -> {
                  final int index = Integer.parseInt(str);
                  setter.accept(options.get(index));
              }
          );
      }
docs: region Helper methods