private static <K, V> AsyncExpiry<K, V> makeAsyncExpiry(long create, long update, long read) { @SuppressWarnings("unchecked") Expiry<K, V> mock = Mockito.mock(Expiry.class); when(mock.expireAfterCreate(any(), any(), anyLong())).thenReturn(create); when(mock.expireAfterUpdate(any(), any(), anyLong(), anyLong())).thenReturn(update); when(mock.expireAfterRead(any(), any(), anyLong(), anyLong())).thenReturn(read); return new AsyncExpiry<>(mock); }
@SuppressWarnings("unchecked") @Nullable Expiry<K, V> getExpiry(boolean isAsync) { return isAsync && (expiry != null) ? (Expiry<K, V>) new AsyncExpiry<>(expiry) : (Expiry<K, V>) expiry; }
@SuppressWarnings("unchecked") @Nullable Expiry<K, V> getExpiry(boolean isAsync) { return isAsync && (expiry != null) ? (Expiry<K, V>) new AsyncExpiry<>(expiry) : (Expiry<K, V>) expiry; }