public Optional<InstantAndValue<T>> getAndSet(MetricKey metricKey, Instant now, T value) {
        InstantAndValue<T> instantAndValue = new InstantAndValue<>(now, value);
        InstantAndValue<T> valueOrNull = counters.put(metricKey, instantAndValue);

        // there wasn't already an entry, so return empty.
        if (valueOrNull == null) {
            return Optional.empty();
        }

        // Return the previous instance and the value.
        return Optional.of(valueOrNull);
    }
@Test
    public void testGetAndSetLong() {
        LastValueTracker<Long> lastValueTracker = new LastValueTracker<>();
        Optional<InstantAndValue<Long>> result = lastValueTracker.getAndSet(METRIC_NAME, instant1, 1L);
        assertFalse(result.isPresent());
    }