aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/basicenumerables/RepresentativeElectionConstraint.java
blob: b97ff55f5c6367e1e41c03ceeca5e20cd0f660a0 (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
/*
 * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package tools.refinery.viatra.runtime.matchers.psystem.basicenumerables;

import tools.refinery.viatra.runtime.matchers.context.IQueryMetaContext;
import tools.refinery.viatra.runtime.matchers.psystem.*;
import tools.refinery.viatra.runtime.matchers.psystem.queries.PQuery;
import tools.refinery.viatra.runtime.matchers.tuple.Tuple;

import java.util.Set;

public class RepresentativeElectionConstraint extends KeyedEnumerablePConstraint<PQuery>
		implements IQueryReference, ITypeInfoProviderConstraint {
	private final Connectivity connectivity;

	public RepresentativeElectionConstraint(PBody pBody, Tuple variablesTuple, PQuery supplierKey,
											Connectivity connectivity) {
		super(pBody, variablesTuple, supplierKey);
		this.connectivity = connectivity;
	}

	public Connectivity getConnectivity() {
		return connectivity;
	}

	@Override
	public PQuery getReferredQuery() {
		return supplierKey;
	}

	@Override
	public Set<TypeJudgement> getImpliedJudgements(IQueryMetaContext context) {
		return PositivePatternCall.getTypesImpliedByCall(supplierKey, variablesTuple);
	}

	@Override
	protected String keyToString() {
		return supplierKey.getFullyQualifiedName() + "#" + connectivity + "#representative";
	}
}