implemented conditions on routes

This commit is contained in:
Stephan Richter
2020-10-30 12:35:04 +01:00
parent d8ce80f2da
commit ce00d21184
11 changed files with 102 additions and 22 deletions

View File

@@ -56,16 +56,21 @@ public abstract class Condition implements Constants {
}
public JSONObject json() {
return new JSONObject().put(TYPE, getClass().getSimpleName());
JSONObject json = new JSONObject().put(TYPE, getClass().getSimpleName());
if (inverted) json.put(INVERTED, true);
return json;
}
public static Condition load(JSONObject json) {
String type = json.getString(TYPE);
Condition condition = null;
switch (type) {
case "TrainSelect":
return TrainSelect.load(json);
condition = TrainSelect.load(json);
break;
}
return null;
if (condition != null) condition.inverted = json.has(INVERTED) && json.getBoolean(INVERTED);
return condition;
}
public Tag link(String tagClass,String context) {