17
17
18
18
import com .arpnetworking .commons .builder .OvalBuilder ;
19
19
import com .arpnetworking .logback .annotations .Loggable ;
20
- import com .arpnetworking .tsdcore .model .Key ;
21
20
import com .google .common .base .MoreObjects ;
22
21
import com .google .common .base .Objects ;
23
- import com .google .common .base .Strings ;
24
22
import com .google .common .collect .ImmutableMap ;
25
- import edu .umd .cs .findbugs .annotations .SuppressFBWarnings ;
26
23
import net .sf .oval .constraint .NotEmpty ;
27
24
import net .sf .oval .constraint .NotNull ;
28
- import net .sf .oval .constraint .ValidateWithMethod ;
29
25
import org .joda .time .DateTime ;
30
26
31
27
/**
32
28
* Default implementation of the <code>Record</code> interface.
33
29
*
34
30
* @author Brandon Arp (brandonarp at gmail dot com)
35
31
* @author Ville Koskela (ville dot koskela at inscopemetrics dot com)
32
+ * @author Ryan Ascheman (rascheman at groupon dot com)
36
33
*/
37
34
@ Loggable
38
35
public final class DefaultRecord implements Record {
@@ -69,6 +66,14 @@ public ImmutableMap<String, String> getAnnotations() {
69
66
return _annotations ;
70
67
}
71
68
69
+ /**
70
+ * {@inheritDoc}
71
+ */
72
+ @ Override
73
+ public ImmutableMap <String , String > getDimensions () {
74
+ return _dimensions ;
75
+ }
76
+
72
77
/**
73
78
* {@inheritDoc}
74
79
*/
@@ -105,6 +110,7 @@ public String toString() {
105
110
.add ("Id" , _id )
106
111
.add ("Time" , _time )
107
112
.add ("Annotations" , _annotations )
113
+ .add ("Dimensions" , _dimensions )
108
114
.toString ();
109
115
}
110
116
@@ -115,12 +121,14 @@ private DefaultRecord(final Builder builder) {
115
121
_id = builder ._id ;
116
122
_time = builder ._time ;
117
123
_annotations = builder ._annotations ;
124
+ _dimensions = builder ._dimensions ;
118
125
}
119
126
120
127
private final ImmutableMap <String , ? extends Metric > _metrics ;
121
128
private final String _id ;
122
129
private final DateTime _time ;
123
130
private final ImmutableMap <String , String > _annotations ;
131
+ private final ImmutableMap <String , String > _dimensions ;
124
132
125
133
/**
126
134
* Implementation of builder pattern for <code>DefaultRecord</code>.
@@ -181,19 +189,16 @@ public Builder setAnnotations(final ImmutableMap<String, String> value) {
181
189
return this ;
182
190
}
183
191
184
- // Called by OVal reflectively
185
- @ SuppressFBWarnings ("UPM_UNCALLED_PRIVATE_METHOD" )
186
- private boolean validateAnnotations (final ImmutableMap <String , String > annotations ) {
187
- if (Strings .isNullOrEmpty (annotations .get (Key .HOST_DIMENSION_KEY ))) {
188
- return false ;
189
- }
190
- if (Strings .isNullOrEmpty (annotations .get (Key .SERVICE_DIMENSION_KEY ))) {
191
- return false ;
192
- }
193
- if (Strings .isNullOrEmpty (annotations .get (Key .CLUSTER_DIMENSION_KEY ))) {
194
- return false ;
195
- }
196
- return true ;
192
+ /**
193
+ * The dimension mappings <code>ImmutableMap</code>. Optional. Default is an empty
194
+ * <code>ImmutableMap</code>. Cannot be null.
195
+ *
196
+ * @param value The dimension mappings <code>ImmutableMap</code>
197
+ * @return This instance of <code>Builder</code>.
198
+ */
199
+ public Builder setDimensions (final ImmutableMap <String , String > value ) {
200
+ _dimensions = value ;
201
+ return this ;
197
202
}
198
203
199
204
@ NotNull
@@ -204,7 +209,8 @@ private boolean validateAnnotations(final ImmutableMap<String, String> annotatio
204
209
@ NotNull
205
210
private DateTime _time ;
206
211
@ NotNull
207
- @ ValidateWithMethod (methodName = "validateAnnotations" , parameterType = ImmutableMap .class )
208
212
private ImmutableMap <String , String > _annotations = ImmutableMap .of ();
213
+ @ NotNull
214
+ private ImmutableMap <String , String > _dimensions = ImmutableMap .of ();
209
215
}
210
216
}
0 commit comments