[New] Added StrolchElementToJsonVisitor.withListParametersAsArray()
This commit is contained in:
parent
7bece7451e
commit
04e5167f60
|
@ -55,6 +55,7 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
|
||||||
private boolean withoutPolicies;
|
private boolean withoutPolicies;
|
||||||
private boolean withoutStateVariables;
|
private boolean withoutStateVariables;
|
||||||
private boolean withoutValueChanges;
|
private boolean withoutValueChanges;
|
||||||
|
private boolean withListParametersAsArray;
|
||||||
private int activityDepth = Integer.MAX_VALUE;
|
private int activityDepth = Integer.MAX_VALUE;
|
||||||
|
|
||||||
public StrolchElementToJsonVisitor() {
|
public StrolchElementToJsonVisitor() {
|
||||||
|
@ -101,6 +102,10 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
|
||||||
return this.withoutValueChanges;
|
return this.withoutValueChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isWithListParametersAsArray() {
|
||||||
|
return this.withListParametersAsArray;
|
||||||
|
}
|
||||||
|
|
||||||
public StrolchElementToJsonVisitor withLocator() {
|
public StrolchElementToJsonVisitor withLocator() {
|
||||||
this.withLocator = true;
|
this.withLocator = true;
|
||||||
return this;
|
return this;
|
||||||
|
@ -156,6 +161,11 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StrolchElementToJsonVisitor withListParametersAsArray() {
|
||||||
|
this.withListParametersAsArray = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public StrolchElementToJsonVisitor activityDepth(int depth) {
|
public StrolchElementToJsonVisitor activityDepth(int depth) {
|
||||||
this.activityDepth = depth;
|
this.activityDepth = depth;
|
||||||
return this;
|
return this;
|
||||||
|
@ -641,6 +651,19 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
|
||||||
rootJ.addProperty(paramId, (Boolean) param.getValue());
|
rootJ.addProperty(paramId, (Boolean) param.getValue());
|
||||||
} else if (type.isNumber()) {
|
} else if (type.isNumber()) {
|
||||||
rootJ.addProperty(paramId, (Number) param.getValue());
|
rootJ.addProperty(paramId, (Number) param.getValue());
|
||||||
|
} else if (this.withListParametersAsArray && type.isList()) {
|
||||||
|
JsonArray valuesJ = switch (type) {
|
||||||
|
case FLOAT_LIST -> ((FloatListParameter) param).streamValues()
|
||||||
|
.collect(JsonArray::new, JsonArray::add, JsonArray::addAll);
|
||||||
|
case INTEGER_LIST -> ((IntegerListParameter) param).streamValues()
|
||||||
|
.collect(JsonArray::new, JsonArray::add, JsonArray::addAll);
|
||||||
|
case STRING_LIST -> ((StringListParameter) param).streamValues()
|
||||||
|
.collect(JsonArray::new, JsonArray::add, JsonArray::addAll);
|
||||||
|
case LONG_LIST -> ((LongListParameter) param).streamValues()
|
||||||
|
.collect(JsonArray::new, JsonArray::add, JsonArray::addAll);
|
||||||
|
default -> throw new IllegalStateException("Unhandle list type " + type);
|
||||||
|
};
|
||||||
|
rootJ.add(paramId, valuesJ);
|
||||||
} else {
|
} else {
|
||||||
rootJ.addProperty(paramId, param.getValueAsString());
|
rootJ.addProperty(paramId, param.getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,11 @@ public class StrolchRootElementToJsonVisitor implements StrolchRootElementVisito
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StrolchRootElementToJsonVisitor withListParametersAsArray() {
|
||||||
|
this.visitor.withListParametersAsArray();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public StrolchRootElementToJsonVisitor withPolicies() {
|
public StrolchRootElementToJsonVisitor withPolicies() {
|
||||||
this.visitor.withPolicies();
|
this.visitor.withPolicies();
|
||||||
return this;
|
return this;
|
||||||
|
|
Loading…
Reference in New Issue