Skip to content

Commit

Permalink
Adding order and direction to SwitchNode serialization (#346)
Browse files Browse the repository at this point in the history
Signed-off-by: Marin Pinchinat-Loth <marin.pinchinat@rte-france.com>
  • Loading branch information
MarinPinchinatLoth authored Feb 11, 2022
1 parent 8790ed1 commit 4c9d03e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import java.io.IOException;
import java.util.Objects;
import java.util.Optional;

/**
* @author Benoit Jeanson <benoit.jeanson at rte-france.com>
Expand Down Expand Up @@ -50,5 +51,12 @@ public Node getOtherAdjNode(Node adj) {
protected void writeJsonContent(JsonGenerator generator, boolean includeCoordinates) throws IOException {
super.writeJsonContent(generator, includeCoordinates);
generator.writeStringField("kind", kind.name());
Optional<Integer> optOrder = getOrder();
if (optOrder.isPresent()) {
generator.writeNumberField("order", optOrder.get());
}
if (getDirection() != null && getDirection() != BusCell.Direction.UNDEFINED) {
generator.writeStringField("direction", getDirection().name());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@
"y" : 345.0,
"rotationAngle" : 90.0,
"open" : false,
"kind" : "BREAKER"
"kind" : "BREAKER",
"order" : 2,
"direction" : "BOTTOM"
}, {
"type" : "SWITCH",
"id" : "bc2",
Expand All @@ -135,7 +137,8 @@
"y" : 240.0,
"rotationAngle" : 90.0,
"open" : false,
"kind" : "BREAKER"
"kind" : "BREAKER",
"order" : 4
}, {
"type" : "SWITCH",
"id" : "bl1",
Expand Down

0 comments on commit 4c9d03e

Please sign in to comment.