diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-11-04 01:58:42 +0100 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-11-05 19:41:33 +0100 |
commit | 6252cdf7dc40e64008e919d82f823c0729f23d21 (patch) | |
tree | f2c2d539db5cac47cb558aeed25073d13627db87 /subprojects/store/src/main/java | |
parent | feat(frontend): scrollbar annotations (diff) | |
download | refinery-6252cdf7dc40e64008e919d82f823c0729f23d21.tar.gz refinery-6252cdf7dc40e64008e919d82f823c0729f23d21.tar.zst refinery-6252cdf7dc40e64008e919d82f823c0729f23d21.zip |
refactor: rename CallKind to Polarity
Diffstat (limited to 'subprojects/store/src/main/java')
-rw-r--r-- | subprojects/store/src/main/java/tools/refinery/store/query/atom/CallAtom.java | 24 | ||||
-rw-r--r-- | subprojects/store/src/main/java/tools/refinery/store/query/atom/CallKind.java | 11 | ||||
-rw-r--r-- | subprojects/store/src/main/java/tools/refinery/store/query/atom/CallPolarity.java | 11 | ||||
-rw-r--r-- | subprojects/store/src/main/java/tools/refinery/store/query/atom/CountingPolarity.java (renamed from subprojects/store/src/main/java/tools/refinery/store/query/atom/CountCallKind.java) | 2 | ||||
-rw-r--r-- | subprojects/store/src/main/java/tools/refinery/store/query/atom/SimplePolarity.java (renamed from subprojects/store/src/main/java/tools/refinery/store/query/atom/BasicCallKind.java) | 4 |
5 files changed, 26 insertions, 26 deletions
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/CallAtom.java b/subprojects/store/src/main/java/tools/refinery/store/query/atom/CallAtom.java index e52e33ac..9e289a8a 100644 --- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/CallAtom.java +++ b/subprojects/store/src/main/java/tools/refinery/store/query/atom/CallAtom.java | |||
@@ -8,22 +8,22 @@ import java.util.Objects; | |||
8 | import java.util.Set; | 8 | import java.util.Set; |
9 | 9 | ||
10 | public final class CallAtom<T extends RelationLike> extends AbstractSubstitutionAtom<T> { | 10 | public final class CallAtom<T extends RelationLike> extends AbstractSubstitutionAtom<T> { |
11 | private final CallKind kind; | 11 | private final CallPolarity polarity; |
12 | 12 | ||
13 | public CallAtom(CallKind kind, T target, List<Variable> substitution) { | 13 | public CallAtom(CallPolarity polarity, T target, List<Variable> substitution) { |
14 | super(target, substitution); | 14 | super(target, substitution); |
15 | if (kind.isTransitive() && target.getArity() != 2) { | 15 | if (polarity.isTransitive() && target.getArity() != 2) { |
16 | throw new IllegalArgumentException("Transitive closures can only take binary relations"); | 16 | throw new IllegalArgumentException("Transitive closures can only take binary relations"); |
17 | } | 17 | } |
18 | this.kind = kind; | 18 | this.polarity = polarity; |
19 | } | 19 | } |
20 | 20 | ||
21 | public CallAtom(CallKind kind, T target, Variable... substitution) { | 21 | public CallAtom(CallPolarity polarity, T target, Variable... substitution) { |
22 | this(kind, target, List.of(substitution)); | 22 | this(polarity, target, List.of(substitution)); |
23 | } | 23 | } |
24 | 24 | ||
25 | public CallAtom(boolean positive, T target, List<Variable> substitution) { | 25 | public CallAtom(boolean positive, T target, List<Variable> substitution) { |
26 | this(CallKind.fromBoolean(positive), target, substitution); | 26 | this(CallPolarity.fromBoolean(positive), target, substitution); |
27 | } | 27 | } |
28 | 28 | ||
29 | public CallAtom(boolean positive, T target, Variable... substitution) { | 29 | public CallAtom(boolean positive, T target, Variable... substitution) { |
@@ -38,13 +38,13 @@ public final class CallAtom<T extends RelationLike> extends AbstractSubstitution | |||
38 | this(target, List.of(substitution)); | 38 | this(target, List.of(substitution)); |
39 | } | 39 | } |
40 | 40 | ||
41 | public CallKind getKind() { | 41 | public CallPolarity getPolarity() { |
42 | return kind; | 42 | return polarity; |
43 | } | 43 | } |
44 | 44 | ||
45 | @Override | 45 | @Override |
46 | public void collectAllVariables(Set<Variable> variables) { | 46 | public void collectAllVariables(Set<Variable> variables) { |
47 | if (kind.isPositive()) { | 47 | if (polarity.isPositive()) { |
48 | super.collectAllVariables(variables); | 48 | super.collectAllVariables(variables); |
49 | } | 49 | } |
50 | } | 50 | } |
@@ -54,13 +54,13 @@ public final class CallAtom<T extends RelationLike> extends AbstractSubstitution | |||
54 | if (this == o) return true; | 54 | if (this == o) return true; |
55 | if (o == null || getClass() != o.getClass()) return false; | 55 | if (o == null || getClass() != o.getClass()) return false; |
56 | CallAtom<?> that = (CallAtom<?>) o; | 56 | CallAtom<?> that = (CallAtom<?>) o; |
57 | return Objects.equals(kind, that.kind) | 57 | return Objects.equals(polarity, that.polarity) |
58 | && Objects.equals(getTarget(), that.getTarget()) | 58 | && Objects.equals(getTarget(), that.getTarget()) |
59 | && Objects.equals(getSubstitution(), that.getSubstitution()); | 59 | && Objects.equals(getSubstitution(), that.getSubstitution()); |
60 | } | 60 | } |
61 | 61 | ||
62 | @Override | 62 | @Override |
63 | public int hashCode() { | 63 | public int hashCode() { |
64 | return Objects.hash(kind, getTarget(), getSubstitution()); | 64 | return Objects.hash(polarity, getTarget(), getSubstitution()); |
65 | } | 65 | } |
66 | } | 66 | } |
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/CallKind.java b/subprojects/store/src/main/java/tools/refinery/store/query/atom/CallKind.java deleted file mode 100644 index 86066b8e..00000000 --- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/CallKind.java +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | package tools.refinery.store.query.atom; | ||
2 | |||
3 | public sealed interface CallKind permits BasicCallKind, CountCallKind { | ||
4 | boolean isPositive(); | ||
5 | |||
6 | boolean isTransitive(); | ||
7 | |||
8 | static CallKind fromBoolean(boolean positive) { | ||
9 | return positive ? BasicCallKind.POSITIVE : BasicCallKind.NEGATIVE; | ||
10 | } | ||
11 | } | ||
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 new file mode 100644 index 00000000..2ab2b6d2 --- /dev/null +++ b/subprojects/store/src/main/java/tools/refinery/store/query/atom/CallPolarity.java | |||
@@ -0,0 +1,11 @@ | |||
1 | package tools.refinery.store.query.atom; | ||
2 | |||
3 | public sealed interface CallPolarity permits SimplePolarity, CountingPolarity { | ||
4 | boolean isPositive(); | ||
5 | |||
6 | boolean isTransitive(); | ||
7 | |||
8 | static CallPolarity fromBoolean(boolean positive) { | ||
9 | return positive ? SimplePolarity.POSITIVE : SimplePolarity.NEGATIVE; | ||
10 | } | ||
11 | } | ||
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/CountCallKind.java b/subprojects/store/src/main/java/tools/refinery/store/query/atom/CountingPolarity.java index 2c85cb4f..08a62f4f 100644 --- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/CountCallKind.java +++ b/subprojects/store/src/main/java/tools/refinery/store/query/atom/CountingPolarity.java | |||
@@ -1,6 +1,6 @@ | |||
1 | package tools.refinery.store.query.atom; | 1 | package tools.refinery.store.query.atom; |
2 | 2 | ||
3 | public record CountCallKind(ComparisonOperator operator, int threshold) implements CallKind { | 3 | public record CountingPolarity(ComparisonOperator operator, int threshold) implements CallPolarity { |
4 | @Override | 4 | @Override |
5 | public boolean isPositive() { | 5 | public boolean isPositive() { |
6 | return false; | 6 | return false; |
diff --git a/subprojects/store/src/main/java/tools/refinery/store/query/atom/BasicCallKind.java b/subprojects/store/src/main/java/tools/refinery/store/query/atom/SimplePolarity.java index cf2ffc07..d243bf26 100644 --- a/subprojects/store/src/main/java/tools/refinery/store/query/atom/BasicCallKind.java +++ b/subprojects/store/src/main/java/tools/refinery/store/query/atom/SimplePolarity.java | |||
@@ -1,6 +1,6 @@ | |||
1 | package tools.refinery.store.query.atom; | 1 | package tools.refinery.store.query.atom; |
2 | 2 | ||
3 | public enum BasicCallKind implements CallKind { | 3 | public enum SimplePolarity implements CallPolarity { |
4 | POSITIVE(true, false), | 4 | POSITIVE(true, false), |
5 | NEGATIVE(false, false), | 5 | NEGATIVE(false, false), |
6 | TRANSITIVE(true, true); | 6 | TRANSITIVE(true, true); |
@@ -9,7 +9,7 @@ public enum BasicCallKind implements CallKind { | |||
9 | 9 | ||
10 | private final boolean transitive; | 10 | private final boolean transitive; |
11 | 11 | ||
12 | BasicCallKind(boolean positive, boolean transitive) { | 12 | SimplePolarity(boolean positive, boolean transitive) { |
13 | this.positive = positive; | 13 | this.positive = positive; |
14 | this.transitive = transitive; | 14 | this.transitive = transitive; |
15 | } | 15 | } |