Skip to content

Commit

Permalink
Now removing NoResults from the prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
quintesse committed Dec 28, 2024
1 parent 5d7543e commit 125be8c
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public Map<String, PromptResultItemIF> prompt(
try {
Map<String, PromptResultItemIF> resultMap = new HashMap<>();
prompt(header, promptableElementList, resultMap);
return resultMap;
return removeNoResults(resultMap);
} finally {
close();
}
Expand Down Expand Up @@ -203,7 +203,7 @@ public Map<String, PromptResultItemIF> prompt(
peResult = new HashMap<>();
}
}
return resultMap;
return removeNoResults(resultMap);
} finally {
// Restore the original state of cancellable
config.setCancellableFirstPrompt(cancellable);
Expand Down Expand Up @@ -403,6 +403,12 @@ private void removePreviousResult(PromptableElementIF pe) {
}
}

private Map<String, PromptResultItemIF> removeNoResults(Map<String, PromptResultItemIF> resultMap) {
return resultMap.entrySet().stream()
.filter(e -> !(e.getValue() instanceof NoResult))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}

/**
* Creates a {@link PromptBuilder}.
*
Expand Down

0 comments on commit 125be8c

Please sign in to comment.