com.codahale.metrics.DefaultSettableGauge Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of metrics-core Show documentation
Show all versions of metrics-core Show documentation
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.
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;
}
}