diff options
Diffstat (limited to 'subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/rewriters/IFlattenCallPredicate.java')
-rw-r--r-- | subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/rewriters/IFlattenCallPredicate.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/rewriters/IFlattenCallPredicate.java b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/rewriters/IFlattenCallPredicate.java new file mode 100644 index 00000000..7e224e98 --- /dev/null +++ b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/psystem/rewriters/IFlattenCallPredicate.java | |||
@@ -0,0 +1,50 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2015, Marton Bur, Zoltan Ujhelyi, Akos Horvath, Istvan Rath 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 | package tools.refinery.viatra.runtime.matchers.psystem.rewriters; | ||
10 | |||
11 | import tools.refinery.viatra.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
12 | |||
13 | |||
14 | /** | ||
15 | * Interface used by the PQueryFlattener to decide which positive pattern calls to flatten | ||
16 | * | ||
17 | * @author Marton Bur | ||
18 | * | ||
19 | */ | ||
20 | public interface IFlattenCallPredicate { | ||
21 | |||
22 | /** | ||
23 | * Decides whether the called query by the pattern call should be flattened into the caller or not. | ||
24 | * | ||
25 | * @param positivePatternCall | ||
26 | * the pattern call | ||
27 | * @return true if the call should be flattened | ||
28 | */ | ||
29 | boolean shouldFlatten(PositivePatternCall positivePatternCall); | ||
30 | |||
31 | /** | ||
32 | * Flattens only if all operand predicates vote for flattening. | ||
33 | * @author Gabor Bergmann | ||
34 | * @since 2.1 | ||
35 | */ | ||
36 | public static class And implements IFlattenCallPredicate { | ||
37 | private IFlattenCallPredicate[] operands; | ||
38 | public And(IFlattenCallPredicate... operands) { | ||
39 | this.operands = operands; | ||
40 | } | ||
41 | |||
42 | @Override | ||
43 | public boolean shouldFlatten(PositivePatternCall positivePatternCall) { | ||
44 | for (IFlattenCallPredicate operand : operands) { | ||
45 | if (!operand.shouldFlatten(positivePatternCall)) return false; | ||
46 | } | ||
47 | return true; | ||
48 | } | ||
49 | } | ||
50 | } | ||