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

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

Description

@ironjan

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>());
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions