29
29
* A variable and data to describe the input to a statistic calculator.
30
30
*
31
31
* @author Brandon Arp (brandon dot arp at inscopemetrics dot io)
32
+ * @author Ville Koskela (ville dot koskela at inscopemetrics dot io)
32
33
*/
33
34
public final class DefaultMetric implements Metric {
34
35
@@ -42,6 +43,11 @@ public List<Quantity> getValues() {
42
43
return _values ;
43
44
}
44
45
46
+ @ Override
47
+ public List <AggregatedData > getStatistics () {
48
+ return _statistics ;
49
+ }
50
+
45
51
@ Override
46
52
public boolean equals (final Object other ) {
47
53
if (this == other ) {
@@ -54,20 +60,22 @@ public boolean equals(final Object other) {
54
60
55
61
final Metric otherMetric = (Metric ) other ;
56
62
return Objects .equal (getType (), otherMetric .getType ())
57
- && Objects .equal (getValues (), otherMetric .getValues ());
63
+ && Objects .equal (getValues (), otherMetric .getValues ())
64
+ && Objects .equal (getStatistics (), otherMetric .getStatistics ());
58
65
}
59
66
60
67
@ Override
61
68
public int hashCode () {
62
- return Objects .hashCode (getType (), getValues ());
69
+ return Objects .hashCode (getType (), getValues (), getStatistics () );
63
70
}
64
71
65
72
@ Override
66
73
public String toString () {
67
74
return MoreObjects .toStringHelper (this )
68
75
.add ("id" , Integer .toHexString (System .identityHashCode (this )))
69
- .add ("UnitType " , _type )
76
+ .add ("Type " , _type )
70
77
.add ("Values" , _values )
78
+ .add ("Statistics" , _statistics )
71
79
.toString ();
72
80
}
73
81
@@ -86,19 +94,22 @@ public Object toLogValue() {
86
94
return LogValueMapFactory .builder (this )
87
95
.put ("type" , _type )
88
96
.put ("valueSize" , _values .size ())
97
+ .put ("statisticsSize" , _statistics .size ())
89
98
.build ();
90
99
}
91
100
92
101
private DefaultMetric (final Builder builder ) {
93
102
_type = builder ._type ;
94
103
_values = builder ._values ;
104
+ _statistics = builder ._statistics ;
95
105
}
96
106
97
107
private final MetricType _type ;
98
108
private final ImmutableList <Quantity > _values ;
109
+ private final ImmutableList <AggregatedData > _statistics ;
99
110
100
111
/**
101
- * Implementation of builder pattern for <code> DefaultMetric</code> .
112
+ * Implementation of builder pattern for {@link DefaultMetric} .
102
113
*
103
114
* @author Ville Koskela (ville dot koskela at inscopemetrics dot io)
104
115
*/
@@ -112,10 +123,21 @@ public Builder() {
112
123
}
113
124
114
125
/**
115
- * The values <code>List</code>. Cannot be null.
126
+ * The statistics {@code List}. Cannot be null.
127
+ *
128
+ * @param value The values {@code List}.
129
+ * @return This instance of {@link Builder}.
130
+ */
131
+ public Builder setStatistics (final ImmutableList <AggregatedData > value ) {
132
+ _statistics = value ;
133
+ return this ;
134
+ }
135
+
136
+ /**
137
+ * The values {@code List}. Cannot be null.
116
138
*
117
- * @param value The values < code> List</code> .
118
- * @return This instance of <code> Builder</code> .
139
+ * @param value The values {@ code List} .
140
+ * @return This instance of {@link Builder} .
119
141
*/
120
142
public Builder setValues (final ImmutableList <Quantity > value ) {
121
143
_values = value ;
@@ -126,7 +148,7 @@ public Builder setValues(final ImmutableList<Quantity> value) {
126
148
* The metric type. Cannot be null.
127
149
*
128
150
* @param value The metric type.
129
- * @return This instance of <code> Builder</code> .
151
+ * @return This instance of {@link Builder} .
130
152
*/
131
153
public Builder setType (final MetricType value ) {
132
154
_type = value ;
@@ -140,7 +162,9 @@ protected void reset() {
140
162
}
141
163
142
164
@ NotNull
143
- private ImmutableList <Quantity > _values ;
165
+ private ImmutableList <AggregatedData > _statistics = ImmutableList .of ();
166
+ @ NotNull
167
+ private ImmutableList <Quantity > _values = ImmutableList .of ();
144
168
@ NotNull
145
169
private MetricType _type ;
146
170
}
0 commit comments