blob: 5053e7ac9d0f65b36d4dc7ad42445f7f0e336487 (
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
45
46
47
48
49
50
|
/*
* SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/
package tools.refinery.language.semantics.internal;
import tools.refinery.store.representation.TruthValue;
public enum DecisionTreeValue {
UNSET(null),
TRUE(TruthValue.TRUE),
FALSE(TruthValue.FALSE),
UNKNOWN(TruthValue.UNKNOWN),
ERROR(TruthValue.ERROR);
final TruthValue truthValue;
DecisionTreeValue(TruthValue truthValue) {
this.truthValue = truthValue;
}
public TruthValue getTruthValue() {
return truthValue;
}
public TruthValue merge(TruthValue other) {
return truthValue == null ? other : truthValue.merge(other);
}
public DecisionTreeValue overwrite(DecisionTreeValue other) {
return other == UNSET ? this : other;
}
public TruthValue getTruthValueOrElse(TruthValue other) {
return this == UNSET ? other : truthValue;
}
public static DecisionTreeValue fromTruthValue(TruthValue truthValue) {
if (truthValue == null) {
return DecisionTreeValue.UNSET;
}
return switch (truthValue) {
case TRUE -> TRUE;
case FALSE -> FALSE;
case UNKNOWN -> UNKNOWN;
case ERROR -> ERROR;
};
}
}
|