aboutsummaryrefslogtreecommitdiffstats
path: root/store/src/main/java/org/eclipse/viatra/solver/data/model/representation/TruthValue.java
diff options
context:
space:
mode:
Diffstat (limited to 'store/src/main/java/org/eclipse/viatra/solver/data/model/representation/TruthValue.java')
-rw-r--r--store/src/main/java/org/eclipse/viatra/solver/data/model/representation/TruthValue.java47
1 files changed, 27 insertions, 20 deletions
diff --git a/store/src/main/java/org/eclipse/viatra/solver/data/model/representation/TruthValue.java b/store/src/main/java/org/eclipse/viatra/solver/data/model/representation/TruthValue.java
index aeccde9e..049c7eac 100644
--- a/store/src/main/java/org/eclipse/viatra/solver/data/model/representation/TruthValue.java
+++ b/store/src/main/java/org/eclipse/viatra/solver/data/model/representation/TruthValue.java
@@ -1,42 +1,49 @@
1package org.eclipse.viatra.solver.data.model.representation; 1package org.eclipse.viatra.solver.data.model.representation;
2 2
3public class TruthValue { 3public enum TruthValue {
4 public static final TruthValue True = new TruthValue("true"); 4 TRUE("true"),
5 public static final TruthValue False = new TruthValue("false"); 5
6 public static final TruthValue Unknown = new TruthValue("unknown"); 6 FALSE("false"),
7 public static final TruthValue Error = new TruthValue("error"); 7
8 8 UNKNOWN("unknown"),
9
10 ERROR("error");
11
9 private final String name; 12 private final String name;
10 protected TruthValue(String name) { 13
14 private TruthValue(String name) {
11 this.name = name; 15 this.name = name;
12 } 16 }
13 17
14 public String getName() { 18 public String getName() {
15 return name; 19 return name;
16 } 20 }
17 21
18 public static TruthValue toTruthValue(boolean value) { 22 public static TruthValue toTruthValue(boolean value) {
19 if(value) return True; 23 return value ? TRUE : FALSE;
20 else return False;
21 } 24 }
25
22 public boolean isConsistent() { 26 public boolean isConsistent() {
23 return this != Error; 27 return this != ERROR;
24 } 28 }
29
25 public boolean isComplete() { 30 public boolean isComplete() {
26 return this != Unknown; 31 return this != UNKNOWN;
27 } 32 }
33
28 public boolean must() { 34 public boolean must() {
29 return this == True || this == Error; 35 return this == TRUE || this == ERROR;
30 } 36 }
37
31 public boolean may() { 38 public boolean may() {
32 return this == True || this == Unknown; 39 return this == TRUE || this == UNKNOWN;
33 } 40 }
34 41
35 public TruthValue not() { 42 public TruthValue not() {
36 if(this == True) { 43 if (this == TRUE) {
37 return False; 44 return FALSE;
38 } else if(this == False) { 45 } else if (this == FALSE) {
39 return True; 46 return TRUE;
40 } else { 47 } else {
41 return this; 48 return this;
42 } 49 }