@Test public void testEvict() { final SharedPreferencesCache cache = new MapCache(); cache.putString(PREF_KEY_STRING, "pref.value"); assertThat(cache.evict(PREF_KEY_STRING), is(true)); assertThat(cache.contains(PREF_KEY_STRING), is(false)); cache.putStringSet(PREF_KEY_STRING_SET, null); assertThat(cache.evict(PREF_KEY_STRING_SET), is(true)); assertThat(cache.contains(PREF_KEY_STRING_SET), is(false)); cache.putInt(PREF_KEY_INTEGER, 1); assertThat(cache.evict(PREF_KEY_INTEGER), is(true)); assertThat(cache.contains(PREF_KEY_INTEGER), is(false)); cache.putFloat(PREF_KEY_FLOAT, 0.5f); assertThat(cache.evict(PREF_KEY_FLOAT), is(true)); assertThat(cache.contains(PREF_KEY_FLOAT), is(false)); cache.putLong(PREF_KEY_LONG, 1000L); assertThat(cache.evict(PREF_KEY_LONG), is(true)); assertThat(cache.contains(PREF_KEY_LONG), is(false)); cache.putBoolean(PREF_KEY_BOOLEAN, false); assertThat(cache.evict(PREF_KEY_BOOLEAN), is(true)); assertThat(cache.contains(PREF_KEY_BOOLEAN), is(false)); }
@Override public boolean evict(@NonNull final String key) { if (map.containsKey(key)) { this.map.remove(key); return true; } return false; }
MapCache implements SharedPreferencesCache { @Override public boolean evict(@NonNull final String key) { if (map.containsKey(key)) { this.map.remove(key); return true; } return false; } }
MapCache implements SharedPreferencesCache { @Override public boolean evict(@NonNull final String key) { if (map.containsKey(key)) { this.map.remove(key); return true; } return false; }  }
MapCache implements SharedPreferencesCache { @Override public boolean evict(@NonNull final String key) { if (map.containsKey(key)) { this.map.remove(key); return true; } return false; }  @Override boolean isEmpty(); @Override boolean contains(@NonNull final String key); @Override boolean putString(@NonNull final String key, @Nullable final String value); @Override @Nullable String getString(@NonNull final String key); @Override boolean putStringSet(@NonNull final String key, @Nullable final Set<String> values); @SuppressWarnings("unchecked") @Override @Nullable Set<String> getStringSet(@NonNull final String key); @Override boolean putInt(@NonNull final String key, final int value); @Override int getInt(@NonNull final String key); @Override boolean putFloat(@NonNull final String key, final float value); @Override float getFloat(@NonNull final String key); @Override boolean putLong(@NonNull final String key, final long value); @Override long getLong(@NonNull final String key); @Override boolean putBoolean(@NonNull final String key, final boolean value); @Override boolean getBoolean(@NonNull final String key); @Override boolean evict(@NonNull final String key); @Override int evictAll(); }
MapCache implements SharedPreferencesCache { @Override public boolean evict(@NonNull final String key) { if (map.containsKey(key)) { this.map.remove(key); return true; } return false; }  @Override boolean isEmpty(); @Override boolean contains(@NonNull final String key); @Override boolean putString(@NonNull final String key, @Nullable final String value); @Override @Nullable String getString(@NonNull final String key); @Override boolean putStringSet(@NonNull final String key, @Nullable final Set<String> values); @SuppressWarnings("unchecked") @Override @Nullable Set<String> getStringSet(@NonNull final String key); @Override boolean putInt(@NonNull final String key, final int value); @Override int getInt(@NonNull final String key); @Override boolean putFloat(@NonNull final String key, final float value); @Override float getFloat(@NonNull final String key); @Override boolean putLong(@NonNull final String key, final long value); @Override long getLong(@NonNull final String key); @Override boolean putBoolean(@NonNull final String key, final boolean value); @Override boolean getBoolean(@NonNull final String key); @Override boolean evict(@NonNull final String key); @Override int evictAll();  }