diff options
Diffstat (limited to 'subprojects/store-query/src/main/java/tools/refinery/store/query/view/FunctionView.java')
-rw-r--r-- | subprojects/store-query/src/main/java/tools/refinery/store/query/view/FunctionView.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/FunctionView.java b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/FunctionView.java index 1b89e77c..74a5be07 100644 --- a/subprojects/store-query/src/main/java/tools/refinery/store/query/view/FunctionView.java +++ b/subprojects/store-query/src/main/java/tools/refinery/store/query/view/FunctionView.java | |||
@@ -5,10 +5,12 @@ | |||
5 | */ | 5 | */ |
6 | package tools.refinery.store.query.view; | 6 | package tools.refinery.store.query.view; |
7 | 7 | ||
8 | import tools.refinery.store.query.term.Parameter; | 8 | import tools.refinery.store.query.term.*; |
9 | import tools.refinery.store.query.term.ParameterDirection; | ||
10 | import tools.refinery.store.representation.Symbol; | 9 | import tools.refinery.store.representation.Symbol; |
11 | 10 | ||
11 | import java.util.ArrayList; | ||
12 | import java.util.List; | ||
13 | |||
12 | public final class FunctionView<T> extends AbstractFunctionView<T> { | 14 | public final class FunctionView<T> extends AbstractFunctionView<T> { |
13 | public FunctionView(Symbol<T> symbol, String name) { | 15 | public FunctionView(Symbol<T> symbol, String name) { |
14 | super(symbol, name, new Parameter(symbol.valueType(), ParameterDirection.OUT)); | 16 | super(symbol, name, new Parameter(symbol.valueType(), ParameterDirection.OUT)); |
@@ -17,4 +19,18 @@ public final class FunctionView<T> extends AbstractFunctionView<T> { | |||
17 | public FunctionView(Symbol<T> symbol) { | 19 | public FunctionView(Symbol<T> symbol) { |
18 | this(symbol, "function"); | 20 | this(symbol, "function"); |
19 | } | 21 | } |
22 | |||
23 | public <R> AssignedValue<R> aggregate(Aggregator<R, T> aggregator, List<NodeVariable> arguments) { | ||
24 | return targetVariable -> { | ||
25 | var placeholderVariable = Variable.of(getSymbol().valueType()); | ||
26 | var argumentsWithPlaceholder = new ArrayList<Variable>(arguments.size() + 1); | ||
27 | argumentsWithPlaceholder.addAll(arguments); | ||
28 | argumentsWithPlaceholder.add(placeholderVariable); | ||
29 | return aggregateBy(placeholderVariable, aggregator, argumentsWithPlaceholder).toLiteral(targetVariable); | ||
30 | }; | ||
31 | } | ||
32 | |||
33 | public <R> AssignedValue<R> aggregate(Aggregator<R, T> aggregator, NodeVariable... arguments) { | ||
34 | return aggregate(aggregator, List.of(arguments)); | ||
35 | } | ||
20 | } | 36 | } |