如何为这种数据结构创建POJO类?

时间:2019-11-11 15:53:56

标签: java firebase google-cloud-firestore hashmap pojo

我在firestore数据库中的数据结构应该看起来像这样

enter image description here

从图像上看,our_array字段是一个数组,其中包含数据类型的字段-内部有Map。

我需要创建一个简单的POJO以便按设计插入数据。

我当前的POJO课:

class ProductList{
  private boolean availability;
  private Object[] our_array; //I have doubts about this one
  private String product_title;

  … //Getters & setters
}

如何构造上面的数据集,特别是其中包含Map的our_maps数组?

1 个答案:

答案 0 :(得分:0)

首先创建一个产品pojo:

class Product {
  private String productName;
  … 
  …
  // getters / setters
}

然后您的ProductList类可以包含一个产品列表:

class ProductList {
  private boolean availability;
  private List<Product> our_productList; 
  ...
  //Getters & setters
}