1 package com.google.code.jetm.maven.internal;
2
3 import java.util.Collections;
4 import java.util.Map;
5
6 import org.apache.commons.lang.builder.ToStringBuilder;
7
8 import etm.core.aggregation.Aggregate;
9
10
11
12
13
14
15
16
17 public class SimpleAggregate implements Aggregate {
18 private final String name;
19 private final double average;
20 private final double min;
21 private final double max;
22 private final long measurements;
23 private final double total;
24 private final boolean hasChilds;
25 private final Map<?, ?> childs;
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 public SimpleAggregate(String name, double average, double min, double max, long measurements, double total) {
44 this.name = name;
45 this.average = average;
46 this.min = min;
47 this.max = max;
48 this.measurements = measurements;
49 this.total = total;
50 this.hasChilds = false;
51 this.childs = Collections.emptyMap();
52 }
53
54 @Override
55 public boolean equals(Object obj) {
56 if (this == obj)
57 return true;
58
59 if (!(obj instanceof Aggregate))
60 return false;
61
62 final Aggregate other = (Aggregate) obj;
63 return getName().equals(other.getName()) && getAverage() == other.getAverage() && getChilds().equals(other.getChilds()) && getMax() == other.getMax()
64 && getMeasurements() == other.getMeasurements() && getMin() == other.getMin() && getTotal() == other.getTotal() && hasChilds() == other.hasChilds();
65 }
66
67
68
69
70 public double getAverage() {
71 return average;
72 }
73
74
75
76
77 public Map<?, ?> getChilds() {
78 return childs;
79 }
80
81
82
83
84 public double getMax() {
85 return max;
86 }
87
88
89
90
91 public long getMeasurements() {
92 return measurements;
93 }
94
95
96
97
98 public double getMin() {
99 return min;
100 }
101
102
103
104
105 public String getName() {
106 return name;
107 }
108
109
110
111
112 public double getTotal() {
113 return total;
114 }
115
116
117
118
119 public boolean hasChilds() {
120 return hasChilds;
121 }
122
123 @Override
124 public int hashCode() {
125 final int prime = 31;
126 int result = 1;
127 long temp;
128 temp = Double.doubleToLongBits(average);
129 result = prime * result + (int) (temp ^ (temp >>> 32));
130 temp = Double.doubleToLongBits(max);
131 result = prime * result + (int) (temp ^ (temp >>> 32));
132 result = prime * result + (int) (measurements ^ (measurements >>> 32));
133 temp = Double.doubleToLongBits(min);
134 result = prime * result + (int) (temp ^ (temp >>> 32));
135 result = prime * result + ((name == null) ? 0 : name.hashCode());
136 temp = Double.doubleToLongBits(total);
137 result = prime * result + (int) (temp ^ (temp >>> 32));
138 return result;
139 }
140
141 @Override
142 public String toString() {
143 return ToStringBuilder.reflectionToString(this);
144 }
145 }