【发布时间】:2020-07-15 20:10:35
【问题描述】:
我不知道为什么会收到此警告:
W/Firestore:(21.3.1) [CustomClassMapper]:
lh没有设置器/字段。 在 com.example.model.Liturgia 类中找到
获取数据的代码:
DocumentReference calRef = db.collection(CALENDAR_PATH).document(fechaYY).collection(fechaMM).document(fechaDD);
calRef.addSnapshotListener((calSnapshot, e) -> {
if ((calSnapshot != null) && calSnapshot.exists()) {
mLiturgia = calSnapshot.toObject(Liturgia.class);
DocumentReference dataRef = calSnapshot.getDocumentReference("lh.1");
// ...
型号
public class Liturgia {
private Breviario lh;
//...
public Liturgia() {
}
@Exclude
public void getlh() {
}
@PropertyName("lh")
public void setLh(Breviario lh) {
this.lh = lh;
}
}
文件
(A):calRef。
正如你在代码中看到的,我首先阅读了这个文档:
(B):calSnapshot。
然后,在第二种情况下,我阅读了另一份文档,该文档在 (A) 中的 document 类型的一个字段中引用:
我将第二个文档映射到Liturgia.class。
如果我尝试将方法命名为 set lh() 或尝试不使用 @PropertyName("lh"),则警告始终显示。
代码按预期工作,但我不想看到这个警告。
我看到了这个答案:W/Firestore: [CustomClassMapper]: No setter/field for class Android 但在我的情况下,属性的名称和方法的名称是相同的。
【问题讨论】:
-
嘿A.!请编辑您的问题并添加文档的屏幕截图。
-
@AlexMamo 我编辑了问题。
-
我明白了,我马上给你写一个答案。
标签: java android firebase google-cloud-firestore