diff options
Diffstat (limited to 'subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/aggregators/max.java')
-rw-r--r-- | subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/aggregators/max.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/aggregators/max.java b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/aggregators/max.java new file mode 100644 index 00000000..e0236223 --- /dev/null +++ b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/matchers/aggregators/max.java | |||
@@ -0,0 +1,44 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2016, Gabor Bergmann, 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.matchers.aggregators; | ||
10 | |||
11 | import java.math.BigDecimal; | ||
12 | import java.math.BigInteger; | ||
13 | import java.util.Calendar; | ||
14 | import java.util.Date; | ||
15 | |||
16 | import tools.refinery.viatra.runtime.matchers.psystem.aggregations.AggregatorType; | ||
17 | import tools.refinery.viatra.runtime.matchers.psystem.aggregations.BoundAggregator; | ||
18 | import tools.refinery.viatra.runtime.matchers.psystem.aggregations.IAggregatorFactory; | ||
19 | |||
20 | /** | ||
21 | * This aggregator calculates the maximum value of a selected aggregate parameter of a called pattern. The aggregate | ||
22 | * parameter is selected with the '#' symbol; the aggregate parameter must not be used outside the aggregator call. The | ||
23 | * other parameters of the call might be bound or unbound; bound parameters limit the matches to consider for the | ||
24 | * minimum calculation. | ||
25 | * | ||
26 | * @since 1.4 | ||
27 | * @author Gabor Bergmann | ||
28 | */ | ||
29 | @AggregatorType( | ||
30 | // TODO T extends Comparable? | ||
31 | parameterTypes = {BigDecimal.class, BigInteger.class, Boolean.class, Byte.class, Calendar.class, Character.class, | ||
32 | Date.class, Double.class, Enum.class, Float.class, Integer.class, Long.class, Short.class, String.class}, | ||
33 | returnTypes = {BigDecimal.class, BigInteger.class, Boolean.class, Byte.class, Calendar.class, Character.class, | ||
34 | Date.class, Double.class, Enum.class, Float.class, Integer.class, Long.class, Short.class, String.class}) | ||
35 | public final class max implements IAggregatorFactory { | ||
36 | |||
37 | @Override | ||
38 | public BoundAggregator getAggregatorLogic(Class<?> domainClass) { | ||
39 | if (Comparable.class.isAssignableFrom(domainClass)) | ||
40 | return new BoundAggregator(ExtremumOperator.getMax(), domainClass, domainClass); | ||
41 | else throw new IllegalArgumentException(); | ||
42 | } | ||
43 | |||
44 | } | ||