aboutsummaryrefslogtreecommitdiffstats
path: root/store/src/main/java/org/eclipse/viatra/solver/data/model/representation/TruthValue.java
blob: aeccde9eeed19c7e4bd8e8ea7efb01d303646eb4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package org.eclipse.viatra.solver.data.model.representation;

public class TruthValue {
	public static final TruthValue True = new TruthValue("true");
	public static final TruthValue False = new TruthValue("false");
	public static final TruthValue Unknown = new TruthValue("unknown");
	public static final TruthValue Error = new TruthValue("error");
	
	private final String name;
	protected TruthValue(String name) {
		this.name = name;
	}
	
	public String getName() {
		return name;
	}
	
	public static TruthValue toTruthValue(boolean value) {
		if(value) return True;
		else return False;
	}
	public boolean isConsistent() {
		return this != Error;
	}
	public boolean isComplete() {
		return this != Unknown;
	}
	public boolean must() {
		return this == True || this == Error;
	}
	public boolean may() {
		return this == True || this == Unknown;
	}
	
	public TruthValue not() {
		if(this == True) {
			return False;
		} else if(this == False) {
			return True;
		} else {
			return this;
		}
	}
}