Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.yammer.metrics.util;
 
 
Returns a 1 the first time it's called, a 0 every time after that.
 
public class ToggleGauge extends Gauge<Integer> {
    private final AtomicInteger value = new AtomicInteger(1);
    @Override
    public Integer value() {
        try {
            return .get();
        } finally {
            this..set(0);
        }
    }
New to GrepCode? Check out our FAQ X