[New] Added StrolchElementToJsonVisitor.withBagId()

This commit is contained in:
Robert von Burg 2022-06-17 15:33:32 +02:00
parent 25f6729621
commit 93ff0f0d02
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
2 changed files with 15 additions and 1 deletions

View File

@ -51,6 +51,7 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
private boolean withoutElementName;
private boolean withoutObjectType;
private boolean withLocator;
private boolean withBagId;
private boolean withoutVersion;
private boolean withoutPolicies;
private boolean withoutStateVariables;
@ -106,6 +107,11 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
return this.withListParametersAsArray;
}
public StrolchElementToJsonVisitor withBagId() {
this.withBagId = true;
return this;
}
public StrolchElementToJsonVisitor withLocator() {
this.withLocator = true;
return this;
@ -405,6 +411,8 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
if (isFlat() || isBagFlat(bag)) {
JsonObject bagJ = new JsonObject();
if (this.withBagId)
bagJ.addProperty(ID, bag.getId());
Set<String> ignoredParamIds = this.ignoredKeys.getSet(bag.getId());
addParameterBagFlat(bagJ, ignoredParamIds, bag);
@ -678,7 +686,8 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
JsonObject paramsJ = new JsonObject();
bagJ.add(PARAMETERS, paramsJ);
bag.streamOfParameters().sorted(comparing(Parameter::getIndex))
bag.streamOfParameters()
.sorted(comparing(Parameter::getIndex))
.forEach(param -> paramsJ.add(param.getId(), paramToJsonFull(param)));
if (this.bagHook != null)

View File

@ -54,6 +54,11 @@ public class StrolchRootElementToJsonVisitor implements StrolchRootElementVisito
return this::visitActivity;
}
public StrolchRootElementToJsonVisitor withBagId() {
this.visitor.withBagId();
return this;
}
public StrolchRootElementToJsonVisitor withLocator() {
this.visitor.withLocator();
return this;