@Test void testShouldThrowIllegalArgumentExceptionWhenKeyIsNullOnGet() { assertThrows(IllegalArgumentException.class, () -> testSubject.get(null)); }
@Override @SuppressWarnings("unchecked") public <K, V> V get(K key) { Assert.nonNull(key, () -> "Key may not be null"); purgeItems(); final Reference<Object> entry = cache.get(key); final V returnValue = entry == null ? null : (V) entry.get(); if (returnValue != null) { for (EntryListener adapter : adapters) { adapter.onEntryRead(key, returnValue); } } return returnValue; }
WeakReferenceCache implements Cache { @Override @SuppressWarnings("unchecked") public <K, V> V get(K key) { Assert.nonNull(key, () -> "Key may not be null"); purgeItems(); final Reference<Object> entry = cache.get(key); final V returnValue = entry == null ? null : (V) entry.get(); if (returnValue != null) { for (EntryListener adapter : adapters) { adapter.onEntryRead(key, returnValue); } } return returnValue; } }
WeakReferenceCache implements Cache { @Override @SuppressWarnings("unchecked") public <K, V> V get(K key) { Assert.nonNull(key, () -> "Key may not be null"); purgeItems(); final Reference<Object> entry = cache.get(key); final V returnValue = entry == null ? null : (V) entry.get(); if (returnValue != null) { for (EntryListener adapter : adapters) { adapter.onEntryRead(key, returnValue); } } return returnValue; }  }
WeakReferenceCache implements Cache { @Override @SuppressWarnings("unchecked") public <K, V> V get(K key) { Assert.nonNull(key, () -> "Key may not be null"); purgeItems(); final Reference<Object> entry = cache.get(key); final V returnValue = entry == null ? null : (V) entry.get(); if (returnValue != null) { for (EntryListener adapter : adapters) { adapter.onEntryRead(key, returnValue); } } return returnValue; }  @Override Registration registerCacheEntryListener(EntryListener entryListener); @Override @SuppressWarnings("unchecked") V get(K key); @Override void put(Object key, Object value); @Override boolean putIfAbsent(Object key, Object value); @Override boolean remove(Object key); @Override boolean containsKey(Object key); }
WeakReferenceCache implements Cache { @Override @SuppressWarnings("unchecked") public <K, V> V get(K key) { Assert.nonNull(key, () -> "Key may not be null"); purgeItems(); final Reference<Object> entry = cache.get(key); final V returnValue = entry == null ? null : (V) entry.get(); if (returnValue != null) { for (EntryListener adapter : adapters) { adapter.onEntryRead(key, returnValue); } } return returnValue; }  @Override Registration registerCacheEntryListener(EntryListener entryListener); @Override @SuppressWarnings("unchecked") V get(K key); @Override void put(Object key, Object value); @Override boolean putIfAbsent(Object key, Object value); @Override boolean remove(Object key); @Override boolean containsKey(Object key);  }