improved code related to tag condition
This commit is contained in:
@@ -80,11 +80,9 @@ public abstract class Condition implements Constants {
|
||||
return json;
|
||||
}
|
||||
|
||||
public static Condition load(JSONObject json) {
|
||||
String type = json.getString(TYPE);
|
||||
Condition condition = Condition.create(type);
|
||||
if (condition != null) condition.inverted = json.has(INVERTED) && json.getBoolean(INVERTED);
|
||||
return condition;
|
||||
public Condition load(JSONObject json) {
|
||||
inverted = json.has(INVERTED) && json.getBoolean(INVERTED);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Tag link(String tagClass,String context) {
|
||||
|
||||
@@ -25,10 +25,10 @@ public class TrainHasTag extends Condition {
|
||||
return super.json().put(TAG, tag);
|
||||
}
|
||||
|
||||
public static TrainHasTag load(JSONObject json) {
|
||||
TrainHasTag tl = new TrainHasTag();
|
||||
if (json.has(TAG)) tl.tag = json.getString(TAG);
|
||||
return tl;
|
||||
public Condition load(JSONObject json) {
|
||||
super.load(json);
|
||||
if (json.has(TAG)) tag = json.getString(TAG);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,10 +25,10 @@ public class TrainLength extends Condition {
|
||||
return super.json().put(MAX_LENGTH, maxLength);
|
||||
}
|
||||
|
||||
public static TrainLength load(JSONObject json) {
|
||||
TrainLength tl = new TrainLength();
|
||||
if (json.has(MAX_LENGTH)) tl.maxLength = json.getInt(MAX_LENGTH);
|
||||
return tl;
|
||||
public Condition load(JSONObject json) {
|
||||
super.load(json);
|
||||
if (json.has(MAX_LENGTH)) maxLength = json.getInt(MAX_LENGTH);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,9 +24,10 @@ public class TrainSelect extends Condition {
|
||||
return super.json().put(REALM_TRAIN, train.id);
|
||||
}
|
||||
|
||||
public static TrainSelect load(JSONObject json) {
|
||||
int trainId = json.getInt(REALM_TRAIN);
|
||||
return new TrainSelect().train(Train.get(trainId));
|
||||
public Condition load(JSONObject json) {
|
||||
super.load(json);
|
||||
train(Train.get(json.getInt(REALM_TRAIN)));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user