From db03801ae5eaa67f8c150413f483905184f5bdaa Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Thu, 22 Sep 2022 22:40:33 +0200 Subject: feat: data structure for assertion merging --- .../store/model/representation/TruthValue.java | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'subprojects/store/src') diff --git a/subprojects/store/src/main/java/tools/refinery/store/model/representation/TruthValue.java b/subprojects/store/src/main/java/tools/refinery/store/model/representation/TruthValue.java index 610713f3..a5ba825b 100644 --- a/subprojects/store/src/main/java/tools/refinery/store/model/representation/TruthValue.java +++ b/subprojects/store/src/main/java/tools/refinery/store/model/representation/TruthValue.java @@ -11,7 +11,7 @@ public enum TruthValue { private final String name; - private TruthValue(String name) { + TruthValue(String name) { this.name = name; } @@ -40,12 +40,19 @@ public enum TruthValue { } public TruthValue not() { - if (this == TRUE) { - return FALSE; - } else if (this == FALSE) { - return TRUE; - } else { - return this; - } + return switch (this) { + case TRUE -> FALSE; + case FALSE -> TRUE; + default -> this; + }; + } + + public TruthValue merge(TruthValue other) { + return switch (this) { + case TRUE -> other == UNKNOWN || other == TRUE ? TRUE : ERROR; + case FALSE -> other == TruthValue.UNKNOWN || other == TruthValue.FALSE ? FALSE : ERROR; + case UNKNOWN -> other; + default -> ERROR; + }; } } -- cgit v1.2.3-70-g09d2