blob: 6b4c6340fefcbe8f76068ca3a85c2a8b74582e7b (
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
|
/*
* SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/
package tools.refinery.store.dse.internal.action;
import tools.refinery.store.model.Model;
import tools.refinery.store.tuple.Tuple;
public class ActivationVariable implements ActionVariable {
private final int index;
private Tuple value;
public ActivationVariable() {
this(0);
}
public ActivationVariable(int index) {
this.index = index;
}
@Override
public void fire(Tuple activation) {
value = Tuple.of(activation.get(index));
}
@Override
public ActivationVariable prepare(Model model) {
return this;
}
@Override
public Tuple getValue() {
return value;
}
@Override
public boolean equalsWithSubstitution(AtomicAction other) {
if (other == null || getClass() != other.getClass()) {
return false;
}
var otherAction = (ActivationVariable) other;
if (index != otherAction.index) {
return false;
}
if (value == null) {
return otherAction.value == null;
}
return value.equals(otherAction.value);
}
}
|