diff options
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.java | 44 |
1 files changed, 44 insertions, 0 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 new file mode 100644 index 00000000..aeccde9e --- /dev/null +++ b/store/src/main/java/org/eclipse/viatra/solver/data/model/representation/TruthValue.java | |||
@@ -0,0 +1,44 @@ | |||
1 | package org.eclipse.viatra.solver.data.model.representation; | ||
2 | |||
3 | public class TruthValue { | ||
4 | public static final TruthValue True = new TruthValue("true"); | ||
5 | public static final TruthValue False = new TruthValue("false"); | ||
6 | public static final TruthValue Unknown = new TruthValue("unknown"); | ||
7 | public static final TruthValue Error = new TruthValue("error"); | ||
8 | |||
9 | private final String name; | ||
10 | protected TruthValue(String name) { | ||
11 | this.name = name; | ||
12 | } | ||
13 | |||
14 | public String getName() { | ||
15 | return name; | ||
16 | } | ||
17 | |||
18 | public static TruthValue toTruthValue(boolean value) { | ||
19 | if(value) return True; | ||
20 | else return False; | ||
21 | } | ||
22 | public boolean isConsistent() { | ||
23 | return this != Error; | ||
24 | } | ||
25 | public boolean isComplete() { | ||
26 | return this != Unknown; | ||
27 | } | ||
28 | public boolean must() { | ||
29 | return this == True || this == Error; | ||
30 | } | ||
31 | public boolean may() { | ||
32 | return this == True || this == Unknown; | ||
33 | } | ||
34 | |||
35 | public TruthValue not() { | ||
36 | if(this == True) { | ||
37 | return False; | ||
38 | } else if(this == False) { | ||
39 | return True; | ||
40 | } else { | ||
41 | return this; | ||
42 | } | ||
43 | } | ||
44 | } | ||