1 package org.kuali.common.jute.base;
2
3 public final class Reducers {
4
5 public static Reducer<Integer, Integer> sumIntegers() {
6 return IntegerReducers.SUM;
7 }
8
9 public static Reducer<Long, Long> sumLongs() {
10 return LongReducers.SUM;
11 }
12
13 public static Reducer<Double, Double> sumDoubles() {
14 return DoubleReducers.SUM;
15 }
16
17 private enum IntegerReducers implements Reducer<Integer, Integer> {
18 SUM {
19 @Override
20 public Integer apply(Integer b, Integer a) {
21 return b + a;
22 }
23 },
24 }
25
26 private enum LongReducers implements Reducer<Long, Long> {
27 SUM {
28 @Override
29 public Long apply(Long b, Long a) {
30 return b + a;
31 }
32 },
33 }
34
35 private enum DoubleReducers implements Reducer<Double, Double> {
36 SUM {
37 @Override
38 public Double apply(Double b, Double a) {
39 return b + a;
40 }
41 },
42 }
43
44 }