aboutsummaryrefslogtreecommitdiffstats
path: root/store/src/main/java/org/eclipse/viatra/solver/data/query/building/PredicateAtom.java
blob: 439298d0fe979c7acd5aa64467828399cb2fec0e (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
package org.eclipse.viatra.solver.data.query.building;

import java.util.List;
import java.util.Map;
import java.util.Set;

public class PredicateAtom implements DNFAtom {
	private DNFPredicate referred;
	private List<Variable> substitution;
	private boolean positive;
	private boolean transitive;

	public PredicateAtom(boolean positive, boolean transitive, DNFPredicate referred, List<Variable> substitution) {
		this.positive = positive;
		this.referred = referred;
		this.substitution = substitution;
		this.transitive = transitive;
	}

	public DNFPredicate getReferred() {
		return referred;
	}

	public void setReferred(DNFPredicate referred) {
		this.referred = referred;
	}

	public List<Variable> getSubstitution() {
		return substitution;
	}

	public void setSubstitution(List<Variable> substitution) {
		this.substitution = substitution;
	}

	public boolean isPositive() {
		return positive;
	}

	public void setPositive(boolean positive) {
		this.positive = positive;
	}

	public boolean isTransitive() {
		return transitive;
	}

	public void setTransitive(boolean transitive) {
		this.transitive = transitive;
	}

	@Override
	public void unifyVariables(Map<String, Variable> variables) {
		for (int i = 0; i < this.substitution.size(); i++) {
			final Object term = this.substitution.get(i);
			if (term instanceof Variable variableReference) {
				this.substitution.set(i, DNFAtom.unifyVariables(variables, variableReference));
			}
		}
	}

	@Override
	public void collectAllVariables(Set<Variable> variables) {
		DNFAtom.addToCollection(variables, substitution);
	}
}