TriggerConnector extends Trigger { @Override Trigger fromJSON(String data) { try { JSONObject d = new JSONObject(data); connectorType = Type.valueOf(JsonHelper.safeGetString(d, "connectorType")); JSONArray array = d.getJSONArray("triggerList"); list.clear(); for (int i = 0; i < array.length(); i++) { Trigger newItem = instantiate(new JSONObject(array.getString(i))); add(newItem); } } catch (JSONException e) { log.error("Unhandled exception", e); } return this; } TriggerConnector();  TriggerConnector(Type connectorType); static void fillIconSet(TriggerConnector connector, HashSet<Integer> set); void changeConnectorType(Type type); Type getConnectorType(); synchronized void add(Trigger t); synchronized void add(int pos, Trigger t); synchronized boolean remove(Trigger t); int size(); Trigger get(int i); int pos(Trigger trigger); @Override synchronized boolean shouldRun(); @Override synchronized String toJSON(); @Override int friendlyName(); @Override String friendlyDescription(); @Override Optional<Integer> icon(); @Override void executed(long time); @Override Trigger duplicate(); void rebuildView(FragmentManager fragmentManager); @Override void generateDialog(LinearLayout root, FragmentManager fragmentManager); TriggerConnector simplify();  }
@Test public void fromJSONTest() throws JSONException { TriggerConnector t = new TriggerConnector(); t.add(new TriggerConnector()); TriggerConnector t2 = (TriggerConnector) Trigger.instantiate(new JSONObject(t.toJSON())); Assert.assertEquals(1, t2.size()); Assert.assertTrue(t2.get(0) instanceof TriggerConnector); }