@Test public void testContainsPreference() { final StringPreference preference = new StringPreference(PREF_KEY, "DefaultValue"); final PreferencesManager manager = new PreferencesManager(context); assertThat(manager.containsPreference(preference), is(false)); assertThat(manager.putPreference(preference, "UpdatedValue"), is(true)); assertThat(manager.containsPreference(preference), is(true)); assertThat(manager.removePreference(preference), is(true)); assertThat(manager.containsPreference(preference), is(false)); }
public final boolean containsPreference(@NonNull final SharedPreference preference) { return contains(preference.getKey()); }
PreferencesManager implements SharedPreferencesFacade, SharedPreferencesProvider { public final boolean containsPreference(@NonNull final SharedPreference preference) { return contains(preference.getKey()); } }
PreferencesManager implements SharedPreferencesFacade, SharedPreferencesProvider { public final boolean containsPreference(@NonNull final SharedPreference preference) { return contains(preference.getKey()); } PreferencesManager(@NonNull final Context context); }
PreferencesManager implements SharedPreferencesFacade, SharedPreferencesProvider { public final boolean containsPreference(@NonNull final SharedPreference preference) { return contains(preference.getKey()); } PreferencesManager(@NonNull final Context context); @NonNull final Context getContext(); @Override void setSharedPreferencesName(@Nullable final String name); @Override @NonNull final String getSharedPreferencesName(); @Override void setSharedPreferencesMode(@SharedPreferencesPolicies.Mode final int mode); @Override @SharedPreferencesPolicies.Mode final int getSharedPreferencesMode(); @Override @NonNull final SharedPreferences getSharedPreferences(); final void setCachingEnabled(final boolean enabled); final boolean isCachingEnabled(); @NonNull final String key(@StringRes final int resId); @Override void registerOnSharedPreferenceChangeListener(@NonNull final SharedPreferences.OnSharedPreferenceChangeListener listener); @Override void unregisterOnSharedPreferenceChangeListener(@NonNull final SharedPreferences.OnSharedPreferenceChangeListener listener); @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, @Nullable final String defValue); @Override boolean putStringSet(@NonNull final String key, @Nullable final Set<String> values); @Override @Nullable Set<String> getStringSet(@NonNull final String key, @Nullable final Set<String> defValues); @Override boolean putInt(@NonNull final String key, final int value); @Override int getInt(@NonNull final String key, final int defValue); @Override boolean putFloat(@NonNull final String key, final float value); @Override float getFloat(@NonNull final String key, final float defValue); @Override boolean putLong(@NonNull final String key, final long value); @Override long getLong(@NonNull final String key, final long defValue); @Override boolean putBoolean(@NonNull final String key, final boolean value); @Override boolean getBoolean(@NonNull final String key, final boolean defValue); @Override boolean remove(@NonNull final String key); @Override int removeAll(); final boolean putPreference(@NonNull final SharedPreference<T> preference, @Nullable final T value); @Nullable final T getPreference(@NonNull final SharedPreference<T> preference); final boolean containsPreference(@NonNull final SharedPreference preference); final boolean removePreference(@NonNull final SharedPreference preference); }
PreferencesManager implements SharedPreferencesFacade, SharedPreferencesProvider { public final boolean containsPreference(@NonNull final SharedPreference preference) { return contains(preference.getKey()); } PreferencesManager(@NonNull final Context context); @NonNull final Context getContext(); @Override void setSharedPreferencesName(@Nullable final String name); @Override @NonNull final String getSharedPreferencesName(); @Override void setSharedPreferencesMode(@SharedPreferencesPolicies.Mode final int mode); @Override @SharedPreferencesPolicies.Mode final int getSharedPreferencesMode(); @Override @NonNull final SharedPreferences getSharedPreferences(); final void setCachingEnabled(final boolean enabled); final boolean isCachingEnabled(); @NonNull final String key(@StringRes final int resId); @Override void registerOnSharedPreferenceChangeListener(@NonNull final SharedPreferences.OnSharedPreferenceChangeListener listener); @Override void unregisterOnSharedPreferenceChangeListener(@NonNull final SharedPreferences.OnSharedPreferenceChangeListener listener); @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, @Nullable final String defValue); @Override boolean putStringSet(@NonNull final String key, @Nullable final Set<String> values); @Override @Nullable Set<String> getStringSet(@NonNull final String key, @Nullable final Set<String> defValues); @Override boolean putInt(@NonNull final String key, final int value); @Override int getInt(@NonNull final String key, final int defValue); @Override boolean putFloat(@NonNull final String key, final float value); @Override float getFloat(@NonNull final String key, final float defValue); @Override boolean putLong(@NonNull final String key, final long value); @Override long getLong(@NonNull final String key, final long defValue); @Override boolean putBoolean(@NonNull final String key, final boolean value); @Override boolean getBoolean(@NonNull final String key, final boolean defValue); @Override boolean remove(@NonNull final String key); @Override int removeAll(); final boolean putPreference(@NonNull final SharedPreference<T> preference, @Nullable final T value); @Nullable final T getPreference(@NonNull final SharedPreference<T> preference); final boolean containsPreference(@NonNull final SharedPreference preference); final boolean removePreference(@NonNull final SharedPreference preference);  }