Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

@DefaultStringSet does not return empty Set of Strings on default #1357

Closed
ironjan opened this issue Mar 27, 2015 · 1 comment · Fixed by #1358
Closed

@DefaultStringSet does not return empty Set of Strings on default #1357

ironjan opened this issue Mar 27, 2015 · 1 comment · Fixed by #1358
Labels

Comments

@ironjan
Copy link

ironjan commented Mar 27, 2015

AA version: 3.2

The documentation of @DefaultStringSet states that an empty Set of Strings is returned on default. The generated code on the other hand returns null by default.

Example:
Base interface:

@SharedPref(SharedPref.Scope.UNIQUE)
public interface PrefsClass {
    /* Documentation of @DefaultStringSet states:
     * "Use on methods in SharedPref annotated class.
     * The generated method will return an empty java.util.Set of Strings by default."
     */
    @DefaultStringSet
    public Set<String> stringSetPref();
}

Generated code:

public final class PrefsClass_ extends SharedPreferencesHelper{
    // ...
    public StringSetPrefField stringSetPref() {
        // returns null instead of empty Set
        return stringSetField("stringSetPref", null);
    }
}

Expected code:

public final class PrefsClass_ extends SharedPreferencesHelper{
    // ...
    public StringSetPrefField stringSetPref() {
        // returns a new empty set (not necessarily HashSet)
        return stringSetField("stringSetPref", new HashSet<String>());
    }
}
@WonderCsabo
Copy link
Member

Thanks for the nicely written bug report! You are correct, i will fix this soon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants