Handly empty type assumptions

This commit is contained in:
Arne Keller 2021-06-18 15:22:24 +02:00
parent 87fd783025
commit 5763c6b4ee

View File

@ -134,9 +134,14 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver {
private void onTypeInferButtonClick() {
termInputField.blur();
String assumptions = assumptionInputField.getValue();
Map<String, String> assumptionsMap = Arrays.stream(assumptions.split(";")).map(entry -> {
Map<String, String> assumptionsMap = Arrays.stream(assumptions.split(";"))
.filter(entry -> entry.length() > 0).map(entry -> {
if (entry.contains(":")) {
String[] parts = entry.split(":", 2);
return Pair.of(parts[0].trim(), parts[1].trim());
} else {
return Pair.of(entry, "");
}
}).collect(Collectors.toMap(Pair::getLeft, Pair::getRight,
(existing, replacement) -> existing, LinkedHashMap::new));
callback.accept(Pair.of(termInputField.getValue(), assumptionsMap));