@Test public void throwsWithNullKey() { LruCache cache = new LruCache(1); try { cache.get(null); fail("Expected NullPointerException"); } catch (NullPointerException expected) { } }
@Override public Bitmap get(@NonNull String key) { if (key == null) { throw new NullPointerException("key == null"); } Bitmap mapValue; synchronized (this) { mapValue = map.get(key); if (mapValue != null) { hitCount++; return mapValue; } missCount++; } return null; }
LruCache implements Cache { @Override public Bitmap get(@NonNull String key) { if (key == null) { throw new NullPointerException("key == null"); } Bitmap mapValue; synchronized (this) { mapValue = map.get(key); if (mapValue != null) { hitCount++; return mapValue; } missCount++; } return null; } }
LruCache implements Cache { @Override public Bitmap get(@NonNull String key) { if (key == null) { throw new NullPointerException("key == null"); } Bitmap mapValue; synchronized (this) { mapValue = map.get(key); if (mapValue != null) { hitCount++; return mapValue; } missCount++; } return null; } LruCache(@NonNull Context context);  LruCache(int maxSize); }
LruCache implements Cache { @Override public Bitmap get(@NonNull String key) { if (key == null) { throw new NullPointerException("key == null"); } Bitmap mapValue; synchronized (this) { mapValue = map.get(key); if (mapValue != null) { hitCount++; return mapValue; } missCount++; } return null; } LruCache(@NonNull Context context);  LruCache(int maxSize); @Override Bitmap get(@NonNull String key); @Override void set(@NonNull String key, @NonNull Bitmap bitmap); final void evictAll(); @Override final synchronized int size(); @Override final synchronized int maxSize(); @Override final synchronized void clear(); @Override final synchronized void clearKeyUri(String uri); final synchronized int hitCount(); final synchronized int missCount(); final synchronized int putCount(); final synchronized int evictionCount(); }
LruCache implements Cache { @Override public Bitmap get(@NonNull String key) { if (key == null) { throw new NullPointerException("key == null"); } Bitmap mapValue; synchronized (this) { mapValue = map.get(key); if (mapValue != null) { hitCount++; return mapValue; } missCount++; } return null; } LruCache(@NonNull Context context);  LruCache(int maxSize); @Override Bitmap get(@NonNull String key); @Override void set(@NonNull String key, @NonNull Bitmap bitmap); final void evictAll(); @Override final synchronized int size(); @Override final synchronized int maxSize(); @Override final synchronized void clear(); @Override final synchronized void clearKeyUri(String uri); final synchronized int hitCount(); final synchronized int missCount(); final synchronized int putCount(); final synchronized int evictionCount();  }