Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
XmlAggregate |
|
| 1.1111111111111112;1.111 |
1 | package com.google.code.jetm.reporting.xml; | |
2 | ||
3 | import java.util.Collections; | |
4 | import java.util.Map; | |
5 | ||
6 | import etm.core.aggregation.Aggregate; | |
7 | ||
8 | /** | |
9 | * An implementation of {@link Aggregate} to be used to marshal and unmarshal to | |
10 | * and from XML. | |
11 | * | |
12 | * @author jrh3k5 | |
13 | * | |
14 | */ | |
15 | ||
16 | public class XmlAggregate implements Aggregate { | |
17 | private final double min; | |
18 | private final double max; | |
19 | private final double total; | |
20 | private final long measurements; | |
21 | private final String name; | |
22 | ||
23 | /** | |
24 | * Create an aggregate. | |
25 | * | |
26 | * @param min | |
27 | * The minimum amount of time that occurred within a measurement | |
28 | * collection. | |
29 | * @param max | |
30 | * The maximum amount of time that occurred within a measurement | |
31 | * collection. | |
32 | * @param total | |
33 | * The total amount of time collected. | |
34 | * @param measurements | |
35 | * The number of times the measurement was collected. | |
36 | * @param name | |
37 | * The name of the measurement. | |
38 | */ | |
39 | 3 | public XmlAggregate(double min, double max, double total, long measurements, String name) { |
40 | 3 | this.min = min; |
41 | 3 | this.max = max; |
42 | 3 | this.total = total; |
43 | 3 | this.name = name; |
44 | 3 | this.measurements = measurements; |
45 | 3 | } |
46 | ||
47 | /** | |
48 | * {@inheritDoc} | |
49 | */ | |
50 | public double getAverage() { | |
51 | 2 | return measurements == 0 ? 0 : total / (double) measurements; |
52 | } | |
53 | ||
54 | /** | |
55 | * {@inheritDoc} | |
56 | */ | |
57 | public Map<?, ?> getChilds() { | |
58 | 0 | return Collections.emptyMap(); |
59 | } | |
60 | ||
61 | /** | |
62 | * {@inheritDoc} | |
63 | */ | |
64 | public double getMax() { | |
65 | 1 | return max; |
66 | } | |
67 | ||
68 | /** | |
69 | * {@inheritDoc} | |
70 | */ | |
71 | public long getMeasurements() { | |
72 | 1 | return measurements; |
73 | } | |
74 | ||
75 | /** | |
76 | * {@inheritDoc} | |
77 | */ | |
78 | public double getMin() { | |
79 | 1 | return min; |
80 | } | |
81 | ||
82 | /** | |
83 | * {@inheritDoc} | |
84 | */ | |
85 | public String getName() { | |
86 | 1 | return name; |
87 | } | |
88 | ||
89 | /** | |
90 | * {@inheritDoc} | |
91 | */ | |
92 | public double getTotal() { | |
93 | 1 | return total; |
94 | } | |
95 | ||
96 | /** | |
97 | * {@inheritDoc} | |
98 | */ | |
99 | public boolean hasChilds() { | |
100 | 0 | return false; |
101 | } | |
102 | ||
103 | } |