blob: 53c32e20a5c9053774dea2b1cdef0814ada842b9 (
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/*
* SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/
package tools.refinery.store.query.term;
import org.jetbrains.annotations.Nullable;
import tools.refinery.store.query.InvalidQueryException;
import tools.refinery.store.query.literal.ConstantLiteral;
import tools.refinery.store.query.literal.EquivalenceLiteral;
import java.util.Optional;
public final class NodeVariable extends Variable {
NodeVariable(@Nullable String name) {
super(name);
}
@Override
public Optional<Class<?>> tryGetType() {
return Optional.empty();
}
@Override
public NodeVariable renew(@Nullable String name) {
return Variable.of(name);
}
@Override
public NodeVariable renew() {
return renew(getExplicitName());
}
@Override
public boolean isNodeVariable() {
return true;
}
@Override
public boolean isDataVariable() {
return false;
}
@Override
public NodeVariable asNodeVariable() {
return this;
}
@Override
public <T> DataVariable<T> asDataVariable(Class<T> type) {
throw new InvalidQueryException("%s is a node variable".formatted(this));
}
@Override
public int hashCodeWithSubstitution(int sequenceNumber) {
return sequenceNumber;
}
public ConstantLiteral isConstant(int value) {
return new ConstantLiteral(this, value);
}
public EquivalenceLiteral isEquivalent(NodeVariable other) {
return new EquivalenceLiteral(true, this, other);
}
public EquivalenceLiteral notEquivalent(NodeVariable other) {
return new EquivalenceLiteral(false, this, other);
}
}
|