SemanticMetricBuilderFactory { public static SemanticMetricBuilder<Histogram> histogramWithReservoir( final Supplier<Reservoir> reservoirSupplier) { return new SemanticMetricBuilder<Histogram>() { @Override public Histogram newMetric() { return new Histogram(reservoirSupplier.get()); } @Override public boolean isInstance(final Metric metric) { return Histogram.class.isInstance(metric); } }; }  static SemanticMetricBuilder<Timer> timerWithReservoir(
        final Supplier<Reservoir> reservoirSupplier); static SemanticMetricBuilder<Histogram> histogramWithReservoir(
        final Supplier<Reservoir> reservoirSupplier);  }
@Test public void histogramWithReservoir() throws Exception { final SemanticMetricBuilder<Histogram> result = SemanticMetricBuilderFactory.histogramWithReservoir(() -> { return new LockFreeExponentiallyDecayingReservoir(); }); assert Histogram.class.isInstance(result.newMetric()); }