aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/NewItemVariable.java
blob: 65b1f54417fd1d2ddf94d4ac0ff3ed079584374b (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
package tools.refinery.store.dse.internal.action;

import tools.refinery.store.dse.DesignSpaceExplorationAdapter;
import tools.refinery.store.model.Model;
import tools.refinery.store.tuple.Tuple;
import tools.refinery.store.tuple.Tuple1;

public class NewItemVariable implements ActionVariable {
	private DesignSpaceExplorationAdapter dseAdapter;
	private Tuple1 value;

	@Override
	public void fire(Tuple activation) {
		value = dseAdapter.createObject();
	}

	@Override
	public NewItemVariable prepare(Model model) {
		dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class);
		return this;
	}

	@Override
	public Tuple1 getValue() {
		return value;
	}

	@Override
	public boolean equalsWithSubstitution(AtomicAction other) {
		if (other == null || getClass() != other.getClass()) {
			return false;
		}
		var otherAction = (NewItemVariable) other;
		if (value == null) {
			return otherAction.value == null;
		}
		return value.equals(otherAction.value);

	}
}