@Test public void testGetLatestDiff() { DummyMetricCollector collector = new DummyMetricCollector(); collector.currentValue = 10; StatefulSystemMetricsCollector<DummyMetric, DummyMetricCollector> statefulCollector = new StatefulSystemMetricsCollector<>(collector); assertThat(statefulCollector.getLatestDiff().value).isEqualTo(0); collector.currentValue = 20; assertThat(statefulCollector.getLatestDiff().value).isEqualTo(10); collector.currentValue = 30; assertThat(statefulCollector.getLatestDiff().value).isEqualTo(20); }
@Nullable public R getLatestDiff() { mIsValid &= mCollector.getSnapshot(this.mCurr); if (!mIsValid) { return null; } mCurr.diff(mPrev, mDiff); return mDiff; }
StatefulSystemMetricsCollector { @Nullable public R getLatestDiff() { mIsValid &= mCollector.getSnapshot(this.mCurr); if (!mIsValid) { return null; } mCurr.diff(mPrev, mDiff); return mDiff; } }
StatefulSystemMetricsCollector { @Nullable public R getLatestDiff() { mIsValid &= mCollector.getSnapshot(this.mCurr); if (!mIsValid) { return null; } mCurr.diff(mPrev, mDiff); return mDiff; } StatefulSystemMetricsCollector(S collector);  StatefulSystemMetricsCollector(S collector, R curr, R prev, R diff); }
StatefulSystemMetricsCollector { @Nullable public R getLatestDiff() { mIsValid &= mCollector.getSnapshot(this.mCurr); if (!mIsValid) { return null; } mCurr.diff(mPrev, mDiff); return mDiff; } StatefulSystemMetricsCollector(S collector);  StatefulSystemMetricsCollector(S collector, R curr, R prev, R diff); S getCollector(); @Nullable R getLatestDiffAndReset(); @Nullable R getLatestDiff(); }
StatefulSystemMetricsCollector { @Nullable public R getLatestDiff() { mIsValid &= mCollector.getSnapshot(this.mCurr); if (!mIsValid) { return null; } mCurr.diff(mPrev, mDiff); return mDiff; } StatefulSystemMetricsCollector(S collector);  StatefulSystemMetricsCollector(S collector, R curr, R prev, R diff); S getCollector(); @Nullable R getLatestDiffAndReset(); @Nullable R getLatestDiff();  }