Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 144ea46c authored by Scott Kennedy's avatar Scott Kennedy Committed by Android (Google) Code Review
Browse files

Merge "Add some @Nullable annotations to SharedPreferences"

parents 72b46d42 2333e340
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.app;

import android.annotation.Nullable;
import android.content.SharedPreferences;
import android.os.FileUtils;
import android.os.Looper;
@@ -217,7 +218,8 @@ final class SharedPreferencesImpl implements SharedPreferences {
        }
    }

    public String getString(String key, String defValue) {
    @Nullable
    public String getString(String key, @Nullable String defValue) {
        synchronized (this) {
            awaitLoadedLocked();
            String v = (String)mMap.get(key);
@@ -225,7 +227,8 @@ final class SharedPreferencesImpl implements SharedPreferences {
        }
    }

    public Set<String> getStringSet(String key, Set<String> defValues) {
    @Nullable
    public Set<String> getStringSet(String key, @Nullable Set<String> defValues) {
        synchronized (this) {
            awaitLoadedLocked();
            Set<String> v = (Set<String>) mMap.get(key);
@@ -303,13 +306,13 @@ final class SharedPreferencesImpl implements SharedPreferences {
        private final Map<String, Object> mModified = Maps.newHashMap();
        private boolean mClear = false;

        public Editor putString(String key, String value) {
        public Editor putString(String key, @Nullable String value) {
            synchronized (this) {
                mModified.put(key, value);
                return this;
            }
        }
        public Editor putStringSet(String key, Set<String> values) {
        public Editor putStringSet(String key, @Nullable Set<String> values) {
            synchronized (this) {
                mModified.put(key,
                        (values == null) ? null : new HashSet<String>(values));
+8 −4
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.content;

import android.annotation.Nullable;

import java.util.Map;
import java.util.Set;

@@ -78,7 +80,7 @@ public interface SharedPreferences {
         * @return Returns a reference to the same Editor object, so you can
         * chain put calls together.
         */
        Editor putString(String key, String value);
        Editor putString(String key, @Nullable String value);
        
        /**
         * Set a set of String values in the preferences editor, to be written
@@ -91,7 +93,7 @@ public interface SharedPreferences {
         * @return Returns a reference to the same Editor object, so you can
         * chain put calls together.
         */
        Editor putStringSet(String key, Set<String> values);
        Editor putStringSet(String key, @Nullable Set<String> values);
        
        /**
         * Set an int value in the preferences editor, to be written back once
@@ -254,7 +256,8 @@ public interface SharedPreferences {
     * 
     * @throws ClassCastException
     */
    String getString(String key, String defValue);
    @Nullable
    String getString(String key, @Nullable String defValue);
    
    /**
     * Retrieve a set of String values from the preferences.
@@ -272,7 +275,8 @@ public interface SharedPreferences {
     * 
     * @throws ClassCastException
     */
    Set<String> getStringSet(String key, Set<String> defValues);
    @Nullable
    Set<String> getStringSet(String key, @Nullable Set<String> defValues);
    
    /**
     * Retrieve an int value from the preferences.