@Override
    public T getValue() {
        T currentValue = this.value.get();
        if (shouldLoad() || currentValue == null) {
            T newValue = loadValue();
            if (!this.value.compareAndSet(currentValue, newValue)) {
                return this.value.get();
            }
            return newValue;
        }
        return currentValue;
    }
@Test
    public void reloadsCachedValueInNegativeTime() throws Exception {
        AtomicLong time = new AtomicLong(-2L);
        Clock clock = new Clock() {
            @Override
            public long getTick() {
                return time.get();
            }
        };
        Gauge<Integer> clockGauge = new CachedGauge<Integer>(clock, 1, TimeUnit.NANOSECONDS) {
            @Override
            protected Integer loadValue() {
                return value.incrementAndGet();
            }
        };
        assertThat(clockGauge.getValue())
                .isEqualTo(1);
        assertThat(clockGauge.getValue())
                .isEqualTo(1);

        time.set(-1L);

        assertThat(clockGauge.getValue())
                .isEqualTo(2);
        assertThat(clockGauge.getValue())
                .isEqualTo(2);
    }