aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/RepresentativeElectionConstraint.java
blob: e146213e39bec44374fed82c72101e5c819126c1 (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
/*
 * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package tools.refinery.store.query.viatra.internal.pquery;

import org.eclipse.viatra.query.runtime.matchers.context.IQueryMetaContext;
import org.eclipse.viatra.query.runtime.matchers.psystem.*;
import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery;
import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
import tools.refinery.store.query.literal.Connectivity;

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() + "#representative";
	}
}