blob: fe9cefccb62c4b5a03b2984977e5b4a009d626e0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/*
* SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/
package tools.refinery.store.query.dnf;
import tools.refinery.store.query.equality.LiteralHashCodeHelper;
import tools.refinery.store.query.term.Parameter;
import tools.refinery.store.query.term.ParameterDirection;
import tools.refinery.store.query.term.Variable;
import java.util.Objects;
public final class SymbolicParameter extends Parameter {
private final Variable variable;
public SymbolicParameter(Variable variable, ParameterDirection direction) {
super(variable.tryGetType().orElse(null), direction);
this.variable = variable;
}
public Variable getVariable() {
return variable;
}
public int hashCodeWithSubstitution(LiteralHashCodeHelper helper) {
return Objects.hash(super.hashCode(), helper.getVariableHashCode(variable));
}
@Override
public String toString() {
var direction = getDirection();
if (direction == ParameterDirection.OUT) {
return variable.toString();
}
return "%s %s".formatted(getDirection(), variable);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
SymbolicParameter that = (SymbolicParameter) o;
return Objects.equals(variable, that.variable);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), variable);
}
}
|