blob: f801163ee588ed97163f450f4bc6b0fe0fc0caa8 (
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
|
/*******************************************************************************
* Copyright (c) 2010-2016, Grill Balázs, IncQueryLabs Ltd.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-v20.html.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package tools.refinery.viatra.runtime.localsearch.matcher.integration;
import java.util.Set;
import java.util.stream.Collectors;
import tools.refinery.viatra.runtime.matchers.psystem.queries.PParameter;
import tools.refinery.viatra.runtime.matchers.psystem.queries.PParameterDirection;
import tools.refinery.viatra.runtime.matchers.psystem.queries.PQueries;
import tools.refinery.viatra.runtime.matchers.psystem.queries.PQuery;
import tools.refinery.viatra.runtime.matchers.util.Sets;
/**
* This implementation calculates all valid adornments for the given query, respecting the parameter direction constraints.
*
* @author Grill Balázs
* @since 1.5
*/
public class AllValidAdornments implements IAdornmentProvider {
@Override
public Iterable<Set<PParameter>> getAdornments(PQuery query) {
final Set<PParameter> ins = query.getParameters().stream().filter(PQueries.parameterDirectionPredicate(PParameterDirection.IN)).collect(Collectors.toSet());
Set<PParameter> inouts = query.getParameters().stream().filter(PQueries.parameterDirectionPredicate(PParameterDirection.INOUT)).collect(Collectors.toSet());
Set<? extends Set<PParameter>> possibleInouts = Sets.powerSet(inouts);
return possibleInouts.stream().map(input -> Sets.union(ins, input)).collect(Collectors.toSet());
}
}
|