From 5763c6b4eea28cb5b17b66e25a3304d4ae1890c4 Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Fri, 18 Jun 2021 15:22:24 +0200 Subject: [PATCH] Handly empty type assumptions --- .../java/edu/kit/typicalc/view/main/InputBar.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/kit/typicalc/view/main/InputBar.java b/src/main/java/edu/kit/typicalc/view/main/InputBar.java index 4fe5275..99564c4 100644 --- a/src/main/java/edu/kit/typicalc/view/main/InputBar.java +++ b/src/main/java/edu/kit/typicalc/view/main/InputBar.java @@ -134,9 +134,14 @@ public class InputBar extends HorizontalLayout implements LocaleChangeObserver { private void onTypeInferButtonClick() { termInputField.blur(); String assumptions = assumptionInputField.getValue(); - Map assumptionsMap = Arrays.stream(assumptions.split(";")).map(entry -> { - String[] parts = entry.split(":", 2); - return Pair.of(parts[0].trim(), parts[1].trim()); + Map 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));