MaxGauge extends Bucketed<Bucket> { public void update(long value) { currentValue.set(value); applyToCurrentBucket(bucket -> bucket.maxValue.accumulateAndGet(value, Long::max)); }  void update(long value); void updateInstantaneous(long value); void add(int delta); long get();  }
@Test public void testWithBucketIdProvider() throws Exception { MaxGauge maxGauge = new MaxGauge(); maxGauge.setBucketIdProvider(bucketIdProvider); maxGauge.update(1); assertPreviousMax(maxGauge, 0); ++bucketIdProvider.id; maxGauge.update(3); maxGauge.update(2); assertPreviousMax(maxGauge, 1); ++bucketIdProvider.id; assertPreviousMax(maxGauge, 3); ++bucketIdProvider.id; assertPreviousMax(maxGauge, 2); }