2
* Copyright 2003-2010 Terracotta, Inc.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
package net.sf.ehcache.search.aggregator;
19
import net.sf.ehcache.search.Attribute;
22
* Helper class to construct the builtin aggregator types. These methods can be statically imported to make query building looker better in
27
public final class Aggregators {
29
private Aggregators() {
34
* Construct a minimum value aggregator
37
* @return min aggregator
39
public static Aggregator min(final Attribute<?> attribute) {
40
return new Aggregator() {
41
public <T> AggregatorInstance<T> createInstance() {
42
return new Min(attribute);
48
* Construct a maximum value aggregator
51
* @return max aggregator
53
public static Aggregator max(final Attribute<?> attribute) {
54
return new Aggregator() {
55
public <T> AggregatorInstance<T> createInstance() {
56
return new Max(attribute);
62
* Construct an average value aggregator
65
* @return average aggregator
67
public static Aggregator average(final Attribute<?> attribute) {
68
return new Aggregator() {
69
public AggregatorInstance<Double> createInstance() {
70
return new Average(attribute);
76
* Construct a sum aggregator
79
* @return sum aggregator
81
public static Aggregator sum(final Attribute<?> attribute) {
82
return new Aggregator() {
83
public AggregatorInstance<Long> createInstance() {
84
return new Sum(attribute);
90
* Construct a counting aggregator
92
* @return count aggregator
94
public static Aggregator count() {
95
return new Aggregator() {
96
public AggregatorInstance<Integer> createInstance() {