我的问题是将问题中的嵌套答案映射到我的Question.class。我尝试在我的Question类中使用Map,以便DataSnapshot.getValue将使用所要求的参数填充该类。我在嵌套结构之上得到了一切。但没有答案,例如A,B,C和D。
这是我的Firebase结构的示例,
我创建的用于映射参数的类。
public class Question {
private String ID;
private String description;
private String resource;
private String source;
private Map<Answer, String> A;
private Map<Answer, String> B;
private Map<Answer, String> C;
private Map<Answer, String> D;
public Map<Answer, String> getA() {
return A;
}
...
public Question(){}
public Question(String ID, String description, String resource, String source) {
this.ID = ID;
this.description = description;
this.resource = resource;
this.source = source;
}
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getResource() {
return resource;
}
public void setResource(String resource) {
this.resource = resource;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
}