TriggerTempTarget extends Trigger { @Override Trigger fromJSON(String data) { try { JSONObject d = new JSONObject(data); lastRun = JsonHelper.safeGetLong(d, "lastRun"); comparator.setValue(ComparatorExists.Compare.valueOf(JsonHelper.safeGetString(d, "comparator"))); } catch (Exception e) { log.error("Unhandled exception", e); } return this; } TriggerTempTarget(); private  TriggerTempTarget(TriggerTempTarget triggerTempTarget); ComparatorExists getComparator(); @Override synchronized boolean shouldRun(); @Override synchronized String toJSON(); @Override int friendlyName(); @Override String friendlyDescription(); @Override Optional<Integer> icon(); @Override Trigger duplicate(); TriggerTempTarget comparator(ComparatorExists.Compare compare); @Override void generateDialog(LinearLayout root, FragmentManager fragmentManager);  }
@Test public void fromJSONTest() throws JSONException { TriggerTempTarget t = new TriggerTempTarget().comparator(ComparatorExists.Compare.NOT_EXISTS); TriggerTempTarget t2 = (TriggerTempTarget) Trigger.instantiate(new JSONObject(t.toJSON())); Assert.assertEquals(ComparatorExists.Compare.NOT_EXISTS, t2.getComparator().getValue()); }