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

Error using auto-value-defensive-copy with auto-value-gson #3

Open
hugonardo opened this issue May 15, 2017 · 0 comments
Open

Error using auto-value-defensive-copy with auto-value-gson #3

hugonardo opened this issue May 15, 2017 · 0 comments

Comments

@hugonardo
Copy link

I have an @AutoValue class that uses Gson's @SerializedName annotation in a Android Project.

On method annotated with @DefensiveCopy and @SerializedName, an error happens in generated class, where @SerializedName's value is not copied.

Follows the code:

@AutoValue
public abstract class UserResponse {

    public static TypeAdapter<UserResponse> typeAdapter(Gson gson) {
        return new AutoValue_UserResponse.GsonTypeAdapter(gson);
    }

    @SerializedName("cod_usuario")
    public abstract String codUsuario();

    @Nullable
    @SerializedName("codigo_motorista")
    public abstract String codMotorista();

    @SerializedName("codigo_veiculo")
    public abstract String codVeiculo();

    @SerializedName("nome_usuario")
    public abstract String nomeDoUsuario();

    @DefensiveCopy
    @SerializedName("grupos")
    public abstract List<String> grupos();
}

abstract class $AutoValue_UserResponse extends $$AutoValue_UserResponse {
  $AutoValue_UserResponse(String codUsuario, @Nullable String codMotorista, String codVeiculo,
      String nomeDoUsuario, List<String> grupos) {
    super(codUsuario, codMotorista, codVeiculo, nomeDoUsuario, grupos);
  }

  @DefensiveCopy
  @SerializedName // <- Here the error. The value "groups" is not copied.
  @Override
  public List<String> grupos() {
    return java.util.Collections.unmodifiableList(super.grupos());
  }
}
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