1717
1818import com .arpnetworking .commons .builder .OvalBuilder ;
1919import com .arpnetworking .logback .annotations .Loggable ;
20- import com .arpnetworking .tsdcore .model .Key ;
2120import com .google .common .base .MoreObjects ;
2221import com .google .common .base .Objects ;
23- import com .google .common .base .Strings ;
2422import com .google .common .collect .ImmutableMap ;
25- import edu .umd .cs .findbugs .annotations .SuppressFBWarnings ;
2623import net .sf .oval .constraint .NotEmpty ;
2724import net .sf .oval .constraint .NotNull ;
28- import net .sf .oval .constraint .ValidateWithMethod ;
2925import org .joda .time .DateTime ;
3026
3127/**
3228 * Default implementation of the <code>Record</code> interface.
3329 *
3430 * @author Brandon Arp (brandonarp at gmail dot com)
3531 * @author Ville Koskela (ville dot koskela at inscopemetrics dot com)
32+ * @author Ryan Ascheman (rascheman at groupon dot com)
3633 */
3734@ Loggable
3835public final class DefaultRecord implements Record {
@@ -69,6 +66,14 @@ public ImmutableMap<String, String> getAnnotations() {
6966 return _annotations ;
7067 }
7168
69+ /**
70+ * {@inheritDoc}
71+ */
72+ @ Override
73+ public ImmutableMap <String , String > getDimensions () {
74+ return _dimensions ;
75+ }
76+
7277 /**
7378 * {@inheritDoc}
7479 */
@@ -105,6 +110,7 @@ public String toString() {
105110 .add ("Id" , _id )
106111 .add ("Time" , _time )
107112 .add ("Annotations" , _annotations )
113+ .add ("Dimensions" , _dimensions )
108114 .toString ();
109115 }
110116
@@ -115,12 +121,14 @@ private DefaultRecord(final Builder builder) {
115121 _id = builder ._id ;
116122 _time = builder ._time ;
117123 _annotations = builder ._annotations ;
124+ _dimensions = builder ._dimensions ;
118125 }
119126
120127 private final ImmutableMap <String , ? extends Metric > _metrics ;
121128 private final String _id ;
122129 private final DateTime _time ;
123130 private final ImmutableMap <String , String > _annotations ;
131+ private final ImmutableMap <String , String > _dimensions ;
124132
125133 /**
126134 * Implementation of builder pattern for <code>DefaultRecord</code>.
@@ -181,19 +189,16 @@ public Builder setAnnotations(final ImmutableMap<String, String> value) {
181189 return this ;
182190 }
183191
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 ;
197202 }
198203
199204 @ NotNull
@@ -204,7 +209,8 @@ private boolean validateAnnotations(final ImmutableMap<String, String> annotatio
204209 @ NotNull
205210 private DateTime _time ;
206211 @ NotNull
207- @ ValidateWithMethod (methodName = "validateAnnotations" , parameterType = ImmutableMap .class )
208212 private ImmutableMap <String , String > _annotations = ImmutableMap .of ();
213+ @ NotNull
214+ private ImmutableMap <String , String > _dimensions = ImmutableMap .of ();
209215 }
210216}
0 commit comments