All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.codahale.metrics.Gauge Maven / Gradle / Ivy

The newest version!
package com.codahale.metrics;

@Deprecated
public interface Gauge extends Metric {

    T getValue();

    @Override
    default io.dropwizard.metrics5.Gauge getDelegate() {
        return new GaugeAdapter<>(this);
    }

    @SuppressWarnings("unchecked")
    static  Gauge of(io.dropwizard.metrics5.Gauge gauge) {
        if (gauge instanceof GaugeAdapter) {
            return ((GaugeAdapter) gauge).delegate;
        }
        return gauge::getValue;
    }

    class GaugeAdapter implements io.dropwizard.metrics5.Gauge {

        private final Gauge delegate;

        GaugeAdapter(Gauge gauge) {
            this.delegate = gauge;
        }

        Gauge getGauge() {
            return delegate;
        }

        @Override
        public T getValue() {
            return delegate.getValue();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy