googleapis / googleapis/google-cloud-java

[java-firestore] Firestore - surprising behavior of object mapping annotations

オープン
#13,146 コメント 5 件 リアクション 1 件 担当者 0 名 GitHub で見る
api: firestore semver: major type: feature request
主要言語
Java
スター
2.1k
フォーク
1.2k
平均マージ
1日 23時間
マージ済み PR(30日)
154

説明

If `com.google.cloud.firestore.annotation.Exclude` annotation used on a property, but not on a getter, it is ignored. The same is true for `@PropertyName`

For @PropertyName it gets even more surprising if the property is public and there is a public getter. In that case a field is duplicated, one instance under the property's name and the other one under the getter's name.

Example that replicates the issue:
```java
class User {
@PropertyName("user_name")
public String name;

@Exclude
private Integer age;

public User(String name, Integer age) {
this.name = name;
this.age = age;
}

public User() {
}

public String getName() {
return name;
}

public Integer getAge() {
return age;
}
}
```

This would produce the following fields:
```
{age=integer_value: 29
, name=string_value: "abc"
, user_name=string_value: "abc"
}
```

But I would expect this:
```
{
user_name=string_value: "abc"
}
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。