diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-12-06 16:13:55 +0100 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-12-09 00:07:39 +0100 |
commit | eedc0ac8c20710e20095e0c19269601c2719543a (patch) | |
tree | 86341ae1eb585eb41167670ab970d2aa6dc16609 /subprojects/store/src/main/java/tools | |
parent | refactor(frontend): theme improvements (diff) | |
download | refinery-eedc0ac8c20710e20095e0c19269601c2719543a.tar.gz refinery-eedc0ac8c20710e20095e0c19269601c2719543a.tar.zst refinery-eedc0ac8c20710e20095e0c19269601c2719543a.zip |
refactor(store): remove CountPolarity
We will have to implement counting in DNF queries in another way.
Diffstat (limited to 'subprojects/store/src/main/java/tools')
5 files changed, 22 insertions, 97 deletions
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/CallPolarity.java b/subprojects/store/src/main/java/tools/refinery/store/query/atom/CallPolarity.java index 2ab2b6d2..957e9b7b 100644 --- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/CallPolarity.java +++ b/subprojects/store/src/main/java/tools/refinery/store/query/atom/CallPolarity.java | |||
@@ -1,11 +1,28 @@ | |||
1 | package tools.refinery.store.query.atom; | 1 | package tools.refinery.store.query.atom; |
2 | 2 | ||
3 | public sealed interface CallPolarity permits SimplePolarity, CountingPolarity { | 3 | public enum CallPolarity { |
4 | boolean isPositive(); | 4 | POSITIVE(true, false), |
5 | NEGATIVE(false, false), | ||
6 | TRANSITIVE(true, true); | ||
5 | 7 | ||
6 | boolean isTransitive(); | 8 | private final boolean positive; |
7 | 9 | ||
8 | static CallPolarity fromBoolean(boolean positive) { | 10 | private final boolean transitive; |
9 | return positive ? SimplePolarity.POSITIVE : SimplePolarity.NEGATIVE; | 11 | |
12 | CallPolarity(boolean positive, boolean transitive) { | ||
13 | this.positive = positive; | ||
14 | this.transitive = transitive; | ||
15 | } | ||
16 | |||
17 | public boolean isPositive() { | ||
18 | return positive; | ||
19 | } | ||
20 | |||
21 | public boolean isTransitive() { | ||
22 | return transitive; | ||
23 | } | ||
24 | |||
25 | public static CallPolarity fromBoolean(boolean positive) { | ||
26 | return positive ? POSITIVE : NEGATIVE; | ||
10 | } | 27 | } |
11 | } | 28 | } |
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/ComparisonOperator.java b/subprojects/store/src/main/java/tools/refinery/store/query/atom/ComparisonOperator.java deleted file mode 100644 index ca113181..00000000 --- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/ComparisonOperator.java +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | package tools.refinery.store.query.atom; | ||
2 | |||
3 | public enum ComparisonOperator { | ||
4 | EQUALS, | ||
5 | NOT_EQUALS, | ||
6 | LESS, | ||
7 | LESS_EQUALS, | ||
8 | GREATER, | ||
9 | GREATER_EQUALS; | ||
10 | |||
11 | @Override | ||
12 | public String toString() { | ||
13 | return switch (this) { | ||
14 | case EQUALS -> "=="; | ||
15 | case NOT_EQUALS -> "!="; | ||
16 | case LESS -> "<"; | ||
17 | case LESS_EQUALS -> "<="; | ||
18 | case GREATER -> ">"; | ||
19 | case GREATER_EQUALS -> ">="; | ||
20 | }; | ||
21 | } | ||
22 | } | ||
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/CountNotEqualsAtom.java b/subprojects/store/src/main/java/tools/refinery/store/query/atom/CountNotEqualsAtom.java deleted file mode 100644 index 312e5fb8..00000000 --- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/CountNotEqualsAtom.java +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | package tools.refinery.store.query.atom; | ||
2 | |||
3 | import tools.refinery.store.model.RelationLike; | ||
4 | import tools.refinery.store.query.Variable; | ||
5 | |||
6 | import java.util.List; | ||
7 | import java.util.Set; | ||
8 | |||
9 | public record CountNotEqualsAtom<T extends RelationLike>(boolean must, int threshold, T mayTarget, T mustTarget, | ||
10 | List<Variable> substitution) implements DNFAtom { | ||
11 | public CountNotEqualsAtom { | ||
12 | if (substitution.size() != mayTarget.getArity()) { | ||
13 | throw new IllegalArgumentException("%s needs %d arguments, but got %s".formatted(mayTarget.getName(), | ||
14 | mayTarget.getArity(), substitution.size())); | ||
15 | } | ||
16 | if (substitution.size() != mustTarget.getArity()) { | ||
17 | throw new IllegalArgumentException("%s needs %d arguments, but got %s".formatted(mustTarget.getName(), | ||
18 | mustTarget.getArity(), substitution.size())); | ||
19 | } | ||
20 | } | ||
21 | |||
22 | public CountNotEqualsAtom(boolean must, int threshold, T mayTarget, T mustTarget, Variable... substitution) { | ||
23 | this(must, threshold, mayTarget, mustTarget, List.of(substitution)); | ||
24 | } | ||
25 | |||
26 | @Override | ||
27 | public void collectAllVariables(Set<Variable> variables) { | ||
28 | // No variables to collect, because all variables should either appear in other clauses, | ||
29 | // or are quantified by this clause. | ||
30 | } | ||
31 | } | ||
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/CountingPolarity.java b/subprojects/store/src/main/java/tools/refinery/store/query/atom/CountingPolarity.java deleted file mode 100644 index 08a62f4f..00000000 --- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/CountingPolarity.java +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | package tools.refinery.store.query.atom; | ||
2 | |||
3 | public record CountingPolarity(ComparisonOperator operator, int threshold) implements CallPolarity { | ||
4 | @Override | ||
5 | public boolean isPositive() { | ||
6 | return false; | ||
7 | } | ||
8 | |||
9 | @Override | ||
10 | public boolean isTransitive() { | ||
11 | return false; | ||
12 | } | ||
13 | } | ||
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/SimplePolarity.java b/subprojects/store/src/main/java/tools/refinery/store/query/atom/SimplePolarity.java deleted file mode 100644 index d243bf26..00000000 --- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/SimplePolarity.java +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | package tools.refinery.store.query.atom; | ||
2 | |||
3 | public enum SimplePolarity implements CallPolarity { | ||
4 | POSITIVE(true, false), | ||
5 | NEGATIVE(false, false), | ||
6 | TRANSITIVE(true, true); | ||
7 | |||
8 | private final boolean positive; | ||
9 | |||
10 | private final boolean transitive; | ||
11 | |||
12 | SimplePolarity(boolean positive, boolean transitive) { | ||
13 | this.positive = positive; | ||
14 | this.transitive = transitive; | ||
15 | } | ||
16 | |||
17 | @Override | ||
18 | public boolean isPositive() { | ||
19 | return positive; | ||
20 | } | ||
21 | |||
22 | @Override | ||
23 | public boolean isTransitive() { | ||
24 | return transitive; | ||
25 | } | ||
26 | } | ||