diff options
Diffstat (limited to 'subprojects/logic/src/main/java/tools/refinery/logic/dnf/SymbolicParameter.java')
-rw-r--r-- | subprojects/logic/src/main/java/tools/refinery/logic/dnf/SymbolicParameter.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/subprojects/logic/src/main/java/tools/refinery/logic/dnf/SymbolicParameter.java b/subprojects/logic/src/main/java/tools/refinery/logic/dnf/SymbolicParameter.java new file mode 100644 index 00000000..acc775a7 --- /dev/null +++ b/subprojects/logic/src/main/java/tools/refinery/logic/dnf/SymbolicParameter.java | |||
@@ -0,0 +1,53 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | package tools.refinery.logic.dnf; | ||
7 | |||
8 | import tools.refinery.logic.equality.LiteralHashCodeHelper; | ||
9 | import tools.refinery.logic.term.Parameter; | ||
10 | import tools.refinery.logic.term.ParameterDirection; | ||
11 | import tools.refinery.logic.term.Variable; | ||
12 | |||
13 | import java.util.Objects; | ||
14 | |||
15 | public final class SymbolicParameter extends Parameter { | ||
16 | private final Variable variable; | ||
17 | |||
18 | public SymbolicParameter(Variable variable, ParameterDirection direction) { | ||
19 | super(variable.tryGetType().orElse(null), direction); | ||
20 | this.variable = variable; | ||
21 | } | ||
22 | |||
23 | public Variable getVariable() { | ||
24 | return variable; | ||
25 | } | ||
26 | |||
27 | public int hashCodeWithSubstitution(LiteralHashCodeHelper helper) { | ||
28 | return Objects.hash(super.hashCode(), helper.getVariableHashCode(variable)); | ||
29 | } | ||
30 | |||
31 | @Override | ||
32 | public String toString() { | ||
33 | var direction = getDirection(); | ||
34 | if (direction == ParameterDirection.OUT) { | ||
35 | return variable.toString(); | ||
36 | } | ||
37 | return "%s %s".formatted(getDirection(), variable); | ||
38 | } | ||
39 | |||
40 | @Override | ||
41 | public boolean equals(Object o) { | ||
42 | if (this == o) return true; | ||
43 | if (o == null || getClass() != o.getClass()) return false; | ||
44 | if (!super.equals(o)) return false; | ||
45 | SymbolicParameter that = (SymbolicParameter) o; | ||
46 | return Objects.equals(variable, that.variable); | ||
47 | } | ||
48 | |||
49 | @Override | ||
50 | public int hashCode() { | ||
51 | return Objects.hash(super.hashCode(), variable); | ||
52 | } | ||
53 | } | ||