Guest User

Untitled

a guest
Apr 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. public static void main(String argv[]) throws Exception {
  2.  
  3. ArrayList<Data> dataArrayList = new ArrayList();
  4. ArrayList<MyObject> dataTypeArrayList = new ArrayList<>();
  5. //Define which type of data will income
  6. dataTypeArrayList.add(new MyObject("acc",AccData.class));
  7. dataTypeArrayList.add(new MyObject("camera",CameraData.class));
  8. dataTypeArrayList.add(new MyObject("dht", DHTData.class));
  9.  
  10. while (true) {
  11. //....
  12.  
  13. JsonParser parser = new JsonParser();
  14. JsonObject json = (JsonObject) parser.parse(line);
  15.  
  16. for (MyObject type :dataTypeArrayList) { //search for DataClasses type
  17.  
  18. String otype = json.get("Type").toString();
  19.  
  20. if(otype.equals(type.getType())){
  21. //how can i call constuctor here?
  22. }
  23. }
  24. }
  25. }
Add Comment
Please, Sign In to add comment