简体   繁体   中英

How would I create a POJO class for such a data structure?

My data structure in firestore database is supposed to look like this

在此处输入图像描述

As from the image, the our_array field, is an array that contains fields of data type - Map inside it.

I need to create a simple POJO in order to insert the data as designed.

My current POJO class:

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

  … //Getters & setters
}

How can I structure the above data set, spefically the our_maps array that contains Map(s) inside it?

First create a Product pojo:

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

then your ProductList class could have a list of Products instead:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM