overhauled storing and loading code for routes, actions and conditions

This commit is contained in:
Stephan Richter
2020-10-30 11:03:39 +01:00
parent 05784f94ce
commit b68b1168c7
8 changed files with 72 additions and 31 deletions

View File

@@ -83,6 +83,18 @@ public class ConditionalAction extends Action {
json.put(ACTIONS, actions.json());
return json;
}
public static ConditionalAction load(JSONObject json) {
ConditionalAction action = new ConditionalAction();
for (Object o : json.getJSONArray(CONDITIONS)) {
if (o instanceof JSONObject) {
Condition condition = Condition.load((JSONObject)o);
if (condition != null) action.conditions.add(condition);
}
}
action.actions = ActionList.load(json.getJSONArray(ACTIONS));
return action;
}
@Override
public Window properties(HashMap<String, String> params) {