@Override public synchronized void addTrigger(Trigger t) throws TriggerLoaderException { t.setTriggerId(triggerCount); t.setLastModifyTime(System.currentTimeMillis()); triggers.put(t.getTriggerId(), t); triggerCount++; }
@Override public Object toJson() { Map<String, Object> jsonObj = new HashMap<String, Object>(); jsonObj.put("actionId", actionId); jsonObj.put("type", type); jsonObj.put("trigger", trigger.toJson()); return jsonObj; }
@SuppressWarnings("unchecked") public static CreateTriggerAction createFromJson(Object obj) throws Exception { Map<String, Object> jsonObj = (HashMap<String, Object>) obj; if (!jsonObj.get("type").equals(type)) { throw new Exception("Cannot create action of " + type + " from " + jsonObj.get("type")); } String actionId = (String) jsonObj.get("actionId"); Trigger trigger = Trigger.fromJson(jsonObj.get("trigger")); return new CreateTriggerAction(actionId, trigger); }
@Override public String getDescription() { return "create another: " + trigger.getDescription(); }