diff options
Diffstat (limited to 'subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/basicenumerables/ConstantValue.java')
-rw-r--r-- | subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/basicenumerables/ConstantValue.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/basicenumerables/ConstantValue.java b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/basicenumerables/ConstantValue.java new file mode 100644 index 00000000..251146c8 --- /dev/null +++ b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/basicenumerables/ConstantValue.java | |||
@@ -0,0 +1,57 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2004-2010 Gabor Bergmann and Daniel Varro | ||
3 | * This program and the accompanying materials are made available under the | ||
4 | * terms of the Eclipse Public License v. 2.0 which is available at | ||
5 | * http://www.eclipse.org/legal/epl-v20.html. | ||
6 | * | ||
7 | * SPDX-License-Identifier: EPL-2.0 | ||
8 | *******************************************************************************/ | ||
9 | |||
10 | package tools.refinery.viatra.runtime.matchers.psystem.basicenumerables; | ||
11 | |||
12 | import java.util.Collections; | ||
13 | import java.util.HashMap; | ||
14 | import java.util.Map; | ||
15 | import java.util.Set; | ||
16 | |||
17 | import tools.refinery.viatra.runtime.matchers.context.IQueryMetaContext; | ||
18 | import tools.refinery.viatra.runtime.matchers.psystem.KeyedEnumerablePConstraint; | ||
19 | import tools.refinery.viatra.runtime.matchers.psystem.PBody; | ||
20 | import tools.refinery.viatra.runtime.matchers.psystem.PVariable; | ||
21 | import tools.refinery.viatra.runtime.matchers.tuple.Tuples; | ||
22 | |||
23 | /** | ||
24 | * @author Gabor Bergmann | ||
25 | * | ||
26 | */ | ||
27 | public class ConstantValue extends KeyedEnumerablePConstraint<Object> { | ||
28 | |||
29 | private PVariable variable; | ||
30 | |||
31 | public ConstantValue(PBody pBody, PVariable variable, Object value) { | ||
32 | super(pBody, Tuples.staticArityFlatTupleOf(variable), value); | ||
33 | this.variable = variable; | ||
34 | } | ||
35 | |||
36 | @Override | ||
37 | protected String keyToString() { | ||
38 | return supplierKey.toString(); | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * @since 1.7 | ||
43 | */ | ||
44 | public PVariable getVariable() { | ||
45 | return variable; | ||
46 | } | ||
47 | |||
48 | @Override | ||
49 | public Map<Set<PVariable>, Set<PVariable>> getFunctionalDependencies(IQueryMetaContext context) { | ||
50 | final Map<Set<PVariable>, Set<PVariable>> result = new HashMap<Set<PVariable>, Set<PVariable>>(); | ||
51 | final Set<PVariable> emptySet = Collections.emptySet(); // a constant value is functionally determined by everything | ||
52 | result.put(emptySet, Collections.singleton(getVariableInTuple(0))); | ||
53 | return result; | ||
54 | } | ||
55 | |||
56 | |||
57 | } | ||