diff options
Diffstat (limited to 'subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/matcher/integration/AllValidAdornments.java')
-rw-r--r-- | subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/matcher/integration/AllValidAdornments.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/matcher/integration/AllValidAdornments.java b/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/matcher/integration/AllValidAdornments.java new file mode 100644 index 00000000..f801163e --- /dev/null +++ b/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/matcher/integration/AllValidAdornments.java | |||
@@ -0,0 +1,37 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2016, Grill Balázs, IncQueryLabs Ltd. | ||
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.localsearch.matcher.integration; | ||
10 | |||
11 | import java.util.Set; | ||
12 | import java.util.stream.Collectors; | ||
13 | |||
14 | import tools.refinery.viatra.runtime.matchers.psystem.queries.PParameter; | ||
15 | import tools.refinery.viatra.runtime.matchers.psystem.queries.PParameterDirection; | ||
16 | import tools.refinery.viatra.runtime.matchers.psystem.queries.PQueries; | ||
17 | import tools.refinery.viatra.runtime.matchers.psystem.queries.PQuery; | ||
18 | import tools.refinery.viatra.runtime.matchers.util.Sets; | ||
19 | |||
20 | |||
21 | /** | ||
22 | * This implementation calculates all valid adornments for the given query, respecting the parameter direction constraints. | ||
23 | * | ||
24 | * @author Grill Balázs | ||
25 | * @since 1.5 | ||
26 | */ | ||
27 | public class AllValidAdornments implements IAdornmentProvider { | ||
28 | |||
29 | @Override | ||
30 | public Iterable<Set<PParameter>> getAdornments(PQuery query) { | ||
31 | final Set<PParameter> ins = query.getParameters().stream().filter(PQueries.parameterDirectionPredicate(PParameterDirection.IN)).collect(Collectors.toSet()); | ||
32 | Set<PParameter> inouts = query.getParameters().stream().filter(PQueries.parameterDirectionPredicate(PParameterDirection.INOUT)).collect(Collectors.toSet()); | ||
33 | Set<? extends Set<PParameter>> possibleInouts = Sets.powerSet(inouts); | ||
34 | return possibleInouts.stream().map(input -> Sets.union(ins, input)).collect(Collectors.toSet()); | ||
35 | } | ||
36 | |||
37 | } | ||