@Test public void isExpired () { expiringObject = new Expiring<>(object, Duration.ofMillis(50)); await().atLeast(100, TimeUnit.MILLISECONDS).atMost(200, TimeUnit.MILLISECONDS).until(() -> expiringObject.getExpiryTime().isBefore(Instant.now())); assertTrue(expiringObject.isExpired()); assertNull(expiringObject.value()); }
boolean isExpired () { Instant now = now(); if (expired) { return true; } else if (now.isAfter(expiryTime)) { expired = true; return true; } return false; }
Expiring { boolean isExpired () { Instant now = now(); if (expired) { return true; } else if (now.isAfter(expiryTime)) { expired = true; return true; } return false; } }
Expiring { boolean isExpired () { Instant now = now(); if (expired) { return true; } else if (now.isAfter(expiryTime)) { expired = true; return true; } return false; } Expiring(T object, Instant expiryTime);  Expiring(T object, long millis);  Expiring(T object, Duration objectDuration); }
Expiring { boolean isExpired () { Instant now = now(); if (expired) { return true; } else if (now.isAfter(expiryTime)) { expired = true; return true; } return false; } Expiring(T object, Instant expiryTime);  Expiring(T object, long millis);  Expiring(T object, Duration objectDuration); T value(); @Override String toString(); void expire(); T computeIfAbsent(Callable<T> callable, long durationInMillis); T computeIfAbsent(Callable<T> callable, Duration objectDuration); }
Expiring { boolean isExpired () { Instant now = now(); if (expired) { return true; } else if (now.isAfter(expiryTime)) { expired = true; return true; } return false; } Expiring(T object, Instant expiryTime);  Expiring(T object, long millis);  Expiring(T object, Duration objectDuration); T value(); @Override String toString(); void expire(); T computeIfAbsent(Callable<T> callable, long durationInMillis); T computeIfAbsent(Callable<T> callable, Duration objectDuration);  }