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

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

Go to download

Metrics is a Java library which gives you unparalleled insight into what your code does in production. Metrics provides a powerful toolkit of ways to measure the behavior of critical components in your production environment.

There is a newer version: 4.2.28
Show newest version
package com.codahale.metrics;

/**
 * Similar to {@link Gauge}, but metric value is updated via calling {@link #setValue(T)} instead.
 */
public class DefaultSettableGauge implements SettableGauge {
    private volatile T value;

    /**
     * Create an instance with no default value.
     */
    public DefaultSettableGauge() {
        this(null);
    }

    /**
     * Create an instance with a default value.
     *
     * @param defaultValue default value
     */
    public DefaultSettableGauge(T defaultValue) {
        this.value = defaultValue;
    }

    /**
     * Set the metric to a new value.
     */
    @Override
    public void setValue(T value) {
        this.value = value;
    }

    /**
     * Returns the current value.
     *
     * @return the current value
     */
    @Override
    public T getValue() {
        return value;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy