@Test public void testValidMetricsLogged() { TimeMetrics timeMetrics = new TimeMetrics(); timeMetrics.realtimeMs = 100; timeMetrics.uptimeMs = 10; CompositeMetrics metrics = new CompositeMetrics().putMetric(TimeMetrics.class, timeMetrics); metrics.setIsValid(TimeMetrics.class, true); mReporter.reportTo(metrics, mEvent); assertThat(mEvent.eventMap.size()).isEqualTo(2); }
public void reportTo(CompositeMetrics metrics, SystemMetricsReporter.Event event) { for (int i = 0; i < mMetricsReporterMap.size(); i++) { Class<? extends SystemMetrics> metricsClass = mMetricsReporterMap.keyAt(i); if (metrics.isValid(metricsClass)) { SystemMetrics systemMetrics = metrics.getMetric(metricsClass); SystemMetricsReporter reporter = mMetricsReporterMap.get(metricsClass); reporter.reportTo(systemMetrics, event); } } }
CompositeMetricsReporter implements SystemMetricsReporter<CompositeMetrics> { public void reportTo(CompositeMetrics metrics, SystemMetricsReporter.Event event) { for (int i = 0; i < mMetricsReporterMap.size(); i++) { Class<? extends SystemMetrics> metricsClass = mMetricsReporterMap.keyAt(i); if (metrics.isValid(metricsClass)) { SystemMetrics systemMetrics = metrics.getMetric(metricsClass); SystemMetricsReporter reporter = mMetricsReporterMap.get(metricsClass); reporter.reportTo(systemMetrics, event); } } } }
CompositeMetricsReporter implements SystemMetricsReporter<CompositeMetrics> { public void reportTo(CompositeMetrics metrics, SystemMetricsReporter.Event event) { for (int i = 0; i < mMetricsReporterMap.size(); i++) { Class<? extends SystemMetrics> metricsClass = mMetricsReporterMap.keyAt(i); if (metrics.isValid(metricsClass)) { SystemMetrics systemMetrics = metrics.getMetric(metricsClass); SystemMetricsReporter reporter = mMetricsReporterMap.get(metricsClass); reporter.reportTo(systemMetrics, event); } } }  }
CompositeMetricsReporter implements SystemMetricsReporter<CompositeMetrics> { public void reportTo(CompositeMetrics metrics, SystemMetricsReporter.Event event) { for (int i = 0; i < mMetricsReporterMap.size(); i++) { Class<? extends SystemMetrics> metricsClass = mMetricsReporterMap.keyAt(i); if (metrics.isValid(metricsClass)) { SystemMetrics systemMetrics = metrics.getMetric(metricsClass); SystemMetricsReporter reporter = mMetricsReporterMap.get(metricsClass); reporter.reportTo(systemMetrics, event); } } }  void reportTo(CompositeMetrics metrics, SystemMetricsReporter.Event event); CompositeMetricsReporter addMetricsReporter(
      Class<T> metricsClass, SystemMetricsReporter<T> reporter); @Nullable T getReporter(
      Class<S> metricsClass); }
CompositeMetricsReporter implements SystemMetricsReporter<CompositeMetrics> { public void reportTo(CompositeMetrics metrics, SystemMetricsReporter.Event event) { for (int i = 0; i < mMetricsReporterMap.size(); i++) { Class<? extends SystemMetrics> metricsClass = mMetricsReporterMap.keyAt(i); if (metrics.isValid(metricsClass)) { SystemMetrics systemMetrics = metrics.getMetric(metricsClass); SystemMetricsReporter reporter = mMetricsReporterMap.get(metricsClass); reporter.reportTo(systemMetrics, event); } } }  void reportTo(CompositeMetrics metrics, SystemMetricsReporter.Event event); CompositeMetricsReporter addMetricsReporter(
      Class<T> metricsClass, SystemMetricsReporter<T> reporter); @Nullable T getReporter(
      Class<S> metricsClass);  }