Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String argv[]) throws Exception {
- ArrayList<Data> dataArrayList = new ArrayList();
- ArrayList<MyObject> dataTypeArrayList = new ArrayList<>();
- //Define which type of data will income
- dataTypeArrayList.add(new MyObject("acc",AccData.class));
- dataTypeArrayList.add(new MyObject("camera",CameraData.class));
- dataTypeArrayList.add(new MyObject("dht", DHTData.class));
- while (true) {
- //....
- JsonParser parser = new JsonParser();
- JsonObject json = (JsonObject) parser.parse(line);
- for (MyObject type :dataTypeArrayList) { //search for DataClasses type
- String otype = json.get("Type").toString();
- if(otype.equals(type.getType())){
- //how can i call constuctor here?
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment