Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Enum type #70

Closed
CoreFloDev opened this issue Oct 12, 2016 · 1 comment
Closed

Support for Enum type #70

CoreFloDev opened this issue Oct 12, 2016 · 1 comment

Comments

@CoreFloDev
Copy link

Hi,

I would like to know if there is a support for enum type with the library

@AutoValue
public abstract class Facility implements Parcelable {

    public enum Codes {
        @SerializedName("CPF") FREE,
        @SerializedName("COP") CHARGEABLE,
        @SerializedName("CPP") CHARGEABLE_ONSITE
    }

    @SerializedName("code")
    public abstract Codes code();

    @SerializedName("legend")
    public abstract String legend();

    @NonNull
    public static TypeAdapter<Facility> typeAdapter(Gson gson) {
        return new AutoValue_Facility.GsonTypeAdapter(gson);
    }
}

According to this answer http://stackoverflow.com/a/18851314 on stackoverflow, this is a valid syntax for Gson, but when I try it I get a null pointer exception.

Thanks

@CoreFloDev
Copy link
Author

My bad, I forgot the @nullable annotation on the code() method because I don't have the entire list of enum value

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

No branches or pull requests

1 participant