[New] Added optional locator to JSON visitors
This commit is contained in:
parent
790f7a0415
commit
102fe87b63
|
@ -41,6 +41,7 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
|
||||||
|
|
||||||
private boolean flat;
|
private boolean flat;
|
||||||
private boolean withoutElementName;
|
private boolean withoutElementName;
|
||||||
|
private boolean withLocator;
|
||||||
private boolean withoutVersion;
|
private boolean withoutVersion;
|
||||||
private boolean withoutPolicies;
|
private boolean withoutPolicies;
|
||||||
private int activityDepth = Integer.MAX_VALUE;
|
private int activityDepth = Integer.MAX_VALUE;
|
||||||
|
@ -59,6 +60,10 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
|
||||||
return !this.withoutVersion;
|
return !this.withoutVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isWithLocator() {
|
||||||
|
return !this.withLocator;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isWithoutVersion() {
|
public boolean isWithoutVersion() {
|
||||||
return this.withoutVersion;
|
return this.withoutVersion;
|
||||||
}
|
}
|
||||||
|
@ -71,6 +76,11 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
|
||||||
return this.withoutPolicies;
|
return this.withoutPolicies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StrolchElementToJsonVisitor withLocator() {
|
||||||
|
this.withLocator = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public StrolchElementToJsonVisitor withVersion() {
|
public StrolchElementToJsonVisitor withVersion() {
|
||||||
this.withoutVersion = false;
|
this.withoutVersion = false;
|
||||||
return this;
|
return this;
|
||||||
|
@ -448,6 +458,8 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
|
||||||
protected JsonObject toJson(AbstractStrolchElement element, JsonObject rootJ) {
|
protected JsonObject toJson(AbstractStrolchElement element, JsonObject rootJ) {
|
||||||
|
|
||||||
rootJ.addProperty(Json.ID, element.getId());
|
rootJ.addProperty(Json.ID, element.getId());
|
||||||
|
if (this.withLocator)
|
||||||
|
rootJ.addProperty(Json.LOCATOR, element.getLocator().toString());
|
||||||
|
|
||||||
if (!isWithoutElementName())
|
if (!isWithoutElementName())
|
||||||
rootJ.addProperty(Json.NAME, element.getName());
|
rootJ.addProperty(Json.NAME, element.getName());
|
||||||
|
|
|
@ -48,6 +48,11 @@ public class StrolchRootElementToJsonVisitor implements StrolchRootElementVisito
|
||||||
return this::visitActivity;
|
return this::visitActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StrolchRootElementToJsonVisitor withLocator() {
|
||||||
|
this.visitor.withLocator();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public StrolchRootElementToJsonVisitor withVersion() {
|
public StrolchRootElementToJsonVisitor withVersion() {
|
||||||
this.visitor.withVersion();
|
this.visitor.withVersion();
|
||||||
return this;
|
return this;
|
||||||
|
|
Loading…
Reference in New Issue