diff options
Diffstat (limited to 'subprojects/logic/src/main/java/tools/refinery/logic/literal/CallPolarity.java')
-rw-r--r-- | subprojects/logic/src/main/java/tools/refinery/logic/literal/CallPolarity.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/subprojects/logic/src/main/java/tools/refinery/logic/literal/CallPolarity.java b/subprojects/logic/src/main/java/tools/refinery/logic/literal/CallPolarity.java new file mode 100644 index 00000000..4f3bca15 --- /dev/null +++ b/subprojects/logic/src/main/java/tools/refinery/logic/literal/CallPolarity.java | |||
@@ -0,0 +1,39 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/> | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | package tools.refinery.logic.literal; | ||
7 | |||
8 | import tools.refinery.logic.InvalidQueryException; | ||
9 | |||
10 | public enum CallPolarity { | ||
11 | POSITIVE(true, false), | ||
12 | NEGATIVE(false, false), | ||
13 | TRANSITIVE(true, true); | ||
14 | |||
15 | private final boolean positive; | ||
16 | |||
17 | private final boolean transitive; | ||
18 | |||
19 | CallPolarity(boolean positive, boolean transitive) { | ||
20 | this.positive = positive; | ||
21 | this.transitive = transitive; | ||
22 | } | ||
23 | |||
24 | public boolean isPositive() { | ||
25 | return positive; | ||
26 | } | ||
27 | |||
28 | public boolean isTransitive() { | ||
29 | return transitive; | ||
30 | } | ||
31 | |||
32 | public CallPolarity negate() { | ||
33 | return switch (this) { | ||
34 | case POSITIVE -> NEGATIVE; | ||
35 | case NEGATIVE -> POSITIVE; | ||
36 | case TRANSITIVE -> throw new InvalidQueryException("Transitive polarity cannot be negated"); | ||
37 | }; | ||
38 | } | ||
39 | } | ||