Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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

Copy link
Copy link
@ironjan

Description

@ironjan
Issue body actions

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>());
    }
}
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.