diff options
Diffstat (limited to 'subprojects/store-query/src/main/java/tools/refinery/store/query/literal/ConstantLiteral.java')
-rw-r--r-- | subprojects/store-query/src/main/java/tools/refinery/store/query/literal/ConstantLiteral.java | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/literal/ConstantLiteral.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/literal/ConstantLiteral.java deleted file mode 100644 index d83bd584..00000000 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/literal/ConstantLiteral.java +++ /dev/null | |||
@@ -1,73 +0,0 @@ | |||
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.store.query.literal; | ||
7 | |||
8 | import tools.refinery.store.query.equality.LiteralEqualityHelper; | ||
9 | import tools.refinery.store.query.equality.LiteralHashCodeHelper; | ||
10 | import tools.refinery.store.query.substitution.Substitution; | ||
11 | import tools.refinery.store.query.term.NodeVariable; | ||
12 | import tools.refinery.store.query.term.Variable; | ||
13 | |||
14 | import java.util.Objects; | ||
15 | import java.util.Set; | ||
16 | |||
17 | public class ConstantLiteral extends AbstractLiteral { | ||
18 | private final NodeVariable variable; | ||
19 | private final int nodeId; | ||
20 | |||
21 | public ConstantLiteral(NodeVariable variable, int nodeId) { | ||
22 | this.variable = variable; | ||
23 | this.nodeId = nodeId; | ||
24 | } | ||
25 | |||
26 | public NodeVariable getVariable() { | ||
27 | return variable; | ||
28 | } | ||
29 | |||
30 | public int getNodeId() { | ||
31 | return nodeId; | ||
32 | } | ||
33 | |||
34 | |||
35 | @Override | ||
36 | public Set<Variable> getOutputVariables() { | ||
37 | return Set.of(variable); | ||
38 | } | ||
39 | |||
40 | @Override | ||
41 | public Set<Variable> getInputVariables(Set<? extends Variable> positiveVariablesInClause) { | ||
42 | return Set.of(); | ||
43 | } | ||
44 | |||
45 | @Override | ||
46 | public Set<Variable> getPrivateVariables(Set<? extends Variable> positiveVariablesInClause) { | ||
47 | return Set.of(); | ||
48 | } | ||
49 | |||
50 | @Override | ||
51 | public ConstantLiteral substitute(Substitution substitution) { | ||
52 | return new ConstantLiteral(substitution.getTypeSafeSubstitute(variable), nodeId); | ||
53 | } | ||
54 | |||
55 | @Override | ||
56 | public boolean equalsWithSubstitution(LiteralEqualityHelper helper, Literal other) { | ||
57 | if (other.getClass() != getClass()) { | ||
58 | return false; | ||
59 | } | ||
60 | var otherConstantLiteral = (ConstantLiteral) other; | ||
61 | return helper.variableEqual(variable, otherConstantLiteral.variable) && nodeId == otherConstantLiteral.nodeId; | ||
62 | } | ||
63 | |||
64 | @Override | ||
65 | public int hashCodeWithSubstitution(LiteralHashCodeHelper helper) { | ||
66 | return Objects.hash(super.hashCodeWithSubstitution(helper), helper.getVariableHashCode(variable), nodeId); | ||
67 | } | ||
68 | |||
69 | @Override | ||
70 | public String toString() { | ||
71 | return "%s === @Constant %d".formatted(variable, nodeId); | ||
72 | } | ||
73 | } | ||