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