1 package com.google.code.jetm.maven.data;
2
3 import java.util.Collections;
4 import java.util.Map;
5
6 import etm.core.aggregation.Aggregate;
7
8
9
10
11
12
13
14
15 public class AggregateSummary implements Aggregate, Comparable<AggregateSummary> {
16 private double min = Double.MAX_VALUE;
17 private double max = Double.MIN_VALUE;
18 private double total;
19 private long measurements;
20 private String name;
21
22
23
24
25
26
27
28 public AggregateSummary(String name) {
29 this.name = name;
30 }
31
32
33
34
35
36
37
38 public void add(Aggregate aggregate) {
39 this.min = Math.min(aggregate.getMin(), getMin());
40 this.max = Math.max(aggregate.getMax(), getMax());
41 this.total += aggregate.getTotal();
42 this.measurements += aggregate.getMeasurements();
43 }
44
45
46
47
48 public int compareTo(AggregateSummary o) {
49 return getName().compareTo(o.getName());
50 }
51
52
53
54
55 public double getAverage() {
56 return getTotal() / getMeasurements();
57 }
58
59
60
61
62 @SuppressWarnings("rawtypes")
63 public Map getChilds() {
64 return Collections.emptyMap();
65 }
66
67
68
69
70 public double getMax() {
71 return max;
72 }
73
74
75
76
77 public long getMeasurements() {
78 return measurements;
79 }
80
81
82
83
84 public double getMin() {
85 return min;
86 }
87
88
89
90
91 public String getName() {
92 return name;
93 }
94
95
96
97
98 public double getTotal() {
99 return total;
100 }
101
102
103
104
105 public boolean hasChilds() {
106 return false;
107 }
108 }